Browse Source

Initial telemetry Pike updates

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

Change-Id: If802d82561619a0b7951422dc0e1e913f2c4c8b4
changes/88/496988/3
Samuel Cassiba 1 year ago
parent
commit
d6736f20ac

+ 0
- 2
.rubocop.yml View File

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

+ 0
- 22
.rubocop_todo.yml View File

@@ -1,22 +0,0 @@
1
-# This configuration was generated by
2
-# `rubocop --auto-gen-config`
3
-# on 2017-08-17 14:16:22 +0200 using RuboCop version 0.47.1.
4
-# The point is for the user to remove these configuration records
5
-# one by one as the offenses are removed from the code base.
6
-# Note that changes in the inspected code, or installation of new
7
-# versions of RuboCop, may require this file to be generated again.
8
-
9
-# Offense count: 20
10
-# Configuration parameters: CountComments, ExcludedMethods.
11
-Metrics/BlockLength:
12
-  Max: 208
13
-
14
-# Offense count: 4
15
-# Configuration parameters: EnforcedStyle, SupportedStyles.
16
-# SupportedStyles: nested, compact
17
-Style/ClassAndModuleChildren:
18
-  Exclude:
19
-    - 'recipes/api.rb'
20
-    - 'recipes/common.rb'
21
-    - 'recipes/gnocchi_configure.rb'
22
-    - 'recipes/identity_registration.rb'

+ 7
- 7
Rakefile View File

@@ -1,20 +1,20 @@
1 1
 task default: ["test"]
2 2
 
3
-task :test => [:lint, :style, :unit]
3
+task :test => [:syntax, :lint, :unit]
4 4
 
5 5
 desc "Vendor the cookbooks in the Berksfile"
6 6
 task :berks_prep do
7 7
   sh %{chef exec berks vendor}
8 8
 end
9 9
 
10
-desc "Run FoodCritic (lint) tests"
11
-task :lint do
12
-  sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .}
10
+desc "Run FoodCritic (syntax) tests"
11
+task :syntax do
12
+  sh %{chef exec foodcritic --exclude spec -f any .}
13 13
 end
14 14
 
15
-desc "Run RuboCop (style) tests"
16
-task :style do
17
-  sh %{chef exec rubocop}
15
+desc "Run RuboCop (lint) tests"
16
+task :lint do
17
+  sh %{chef exec cookstyle}
18 18
 end
19 19
 
20 20
 desc "Run RSpec (unit) tests"

+ 7
- 4
attributes/default.rb View File

@@ -20,8 +20,11 @@
20 20
 #
21 21
 # Set to some text value if you want templated config files
22 22
 # to contain a custom banner at the top of the written file
23
-default['openstack']['telemetry']['custom_template_banner'] =
24
-  '# This file autogenerated by Chef, changes will be overwritten'
23
+default['openstack']['telemetry']['custom_template_banner'] = '
24
+# This file is automatically generated by Chef
25
+# Any changes will be overwritten
26
+'
27
+
25 28
 # Set the endpoints for the telemetry services to allow all other cookbooks to
26 29
 # access and use them
27 30
 %w(telemetry telemetry-metric).each do |ts|
@@ -103,7 +106,7 @@ when 'rhel'
103 106
     'api_service' => 'openstack-ceilometer-api',
104 107
     'collector_packages' => ['openstack-ceilometer-collector'],
105 108
     'collector_service' => 'openstack-ceilometer-collector',
106
-    'package_overrides' => ''
109
+    'package_overrides' => '',
107 110
   }
108 111
 
109 112
 when 'debian'
@@ -124,6 +127,6 @@ when 'debian'
124 127
     'api_service' => 'ceilometer-api',
125 128
     'collector_packages' => ['ceilometer-collector', 'python-mysqldb'],
126 129
     'collector_service' => 'ceilometer-collector',
127
-    'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
130
+    'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'",
128 131
   }
129 132
 end

+ 1
- 1
recipes/common.rb View File

@@ -20,7 +20,7 @@
20 20
 # limitations under the License.
21 21
 #
22 22
 
23
-class ::Chef::Recipe # rubocop:disable Documentation
23
+class ::Chef::Recipe
24 24
   include ::Openstack
25 25
 end
26 26
 

+ 2
- 2
recipes/identity_registration.rb View File

@@ -38,7 +38,7 @@ connection_params = {
38 38
   openstack_username:     admin_user,
39 39
   openstack_api_key:      admin_pass,
40 40
   openstack_project_name: admin_project,
41
-  openstack_domain_name:    admin_domain
41
+  openstack_domain_name:    admin_domain,
42 42
 }
43 43
 
44 44
 %w(telemetry telemetry-metric).each do |telemetry_service|
@@ -54,7 +54,7 @@ connection_params = {
54 54
   interfaces = {
55 55
     public: { url: public_endpoint(telemetry_service) },
56 56
     internal: { url: internal_endpoint(telemetry_service) },
57
-    admin: { url: admin_endpoint(telemetry_service) }
57
+    admin: { url: admin_endpoint(telemetry_service) },
58 58
   }
59 59
 
60 60
   service_pass = get_password 'service', "openstack-#{telemetry_service}"

+ 5
- 5
spec/common_spec.rb View File

@@ -70,7 +70,7 @@ describe 'openstack-telemetry::common' do
70 70
           /^auth_type = v3password$/,
71 71
           /^region_name = RegionOne$/,
72 72
           %r{auth_url = http://127\.0\.0\.1:5000/v3},
73
-          /^password = ceilometer-pass$/
73
+          /^password = ceilometer-pass$/,
74 74
         ].each do |line|
75 75
           expect(chef_run).to render_config_file(file.name)
76 76
             .with_section_content('keystone_authtoken', line)
@@ -87,7 +87,7 @@ describe 'openstack-telemetry::common' do
87 87
           /^interface = internal$/,
88 88
           /^region_name = RegionOne$/,
89 89
           %r{auth_url = http://127\.0\.0\.1:5000/v3},
90
-          /^password = ceilometer-pass$/
90
+          /^password = ceilometer-pass$/,
91 91
         ].each do |line|
92 92
           expect(chef_run).to render_config_file(file.name)
93 93
             .with_section_content('service_credentials', line)
@@ -97,7 +97,7 @@ describe 'openstack-telemetry::common' do
97 97
       it do
98 98
         [
99 99
           /^host = 127\.0\.0\.1$/,
100
-          /^port = 8777$/
100
+          /^port = 8777$/,
101 101
         ].each do |line|
102 102
           expect(chef_run).to render_config_file(file.name)
103 103
             .with_section_content('api', line)
@@ -107,7 +107,7 @@ describe 'openstack-telemetry::common' do
107 107
       it do
108 108
         [
109 109
           %r{url = http://127\.0\.0\.1:8041},
110
-          /^filter_project = service$/
110
+          /^filter_project = service$/,
111 111
         ].each do |line|
112 112
           expect(chef_run).to render_config_file(file.name)
113 113
             .with_section_content('dispatcher_gnocchi', line)
@@ -116,7 +116,7 @@ describe 'openstack-telemetry::common' do
116 116
 
117 117
       it do
118 118
         [
119
-          %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}
119
+          %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$},
120 120
         ].each do |line|
121 121
           expect(chef_run).to render_config_file(file.name)
122 122
             .with_section_content('DEFAULT', line)

+ 2
- 2
spec/gnocchi_configure_spec.rb View File

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

+ 1
- 1
spec/identity_registration_spec.rb View File

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

+ 2
- 2
spec/spec_helper.rb View File

@@ -10,12 +10,12 @@ LOG_LEVEL = :fatal
10 10
 REDHAT_OPTS = {
11 11
   platform: 'redhat',
12 12
   version: '7.1',
13
-  log_level: ::LOG_LEVEL
13
+  log_level: ::LOG_LEVEL,
14 14
 }.freeze
15 15
 UBUNTU_OPTS = {
16 16
   platform: 'ubuntu',
17 17
   version: '14.04',
18
-  log_level: ::LOG_LEVEL
18
+  log_level: ::LOG_LEVEL,
19 19
 }.freeze
20 20
 
21 21
 shared_context 'telemetry-stubs' do

Loading…
Cancel
Save