Skip to content

Commit 84e826d

Browse files
author
Jarret Lavallee
committed
Fix rubocop and spec errors
This commit fixes some spec and rubocop errors due to a rebase with the main branch.
1 parent ee3f582 commit 84e826d

File tree

5 files changed

+38
-49
lines changed

5 files changed

+38
-49
lines changed

files/psql_metrics

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ EOS
514514
['--output_dir DIR',
515515
'Write metrics to a timestamped file under DIR instead of',
516516
'printing to STDOUT'],
517-
['-p', '--[no-]print', 'Always print to STDOUT']].freeze
517+
['-p', '--[no-]print', 'Always print to STDOUT']].freeze
518518

519519
def initialize(argv = [])
520520
@action = :collect_data

files/system_metrics

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ module SystemMetrics
399399

400400
metrics_json = metrics_to_json(metrics_data)
401401

402-
if @print_output != false then
403-
STDOUT.puts(metrics_json)
404-
end
402+
STDOUT.puts(metrics_json) if @print_output
405403
write_metrics_to_file(metrics_json)
406404
end
407405
end
@@ -437,7 +435,7 @@ if $PROGRAM_NAME == __FILE__
437435
options = {}
438436

439437
OptionParser.new { |opts|
440-
opts.banner = "Usage: system_metrics [options]"
438+
opts.banner = 'Usage: system_metrics [options]'
441439

442440
opts.on('-h', '--help', 'Display the help text') do
443441
puts DESCRIPTION
@@ -466,7 +464,7 @@ if $PROGRAM_NAME == __FILE__
466464
'The puppet_metrics_collector output directory') do |metrics_dir|
467465
options[:metrics_dir] = metrics_dir
468466
end
469-
opts.on("-v", "--verbose", String, "Enable Verbose output") { options[:verbose] = true }
467+
opts.on('-v', '--verbose', String, 'Enable Verbose output') { options[:verbose] = true }
470468
opts.on('--[no-]print', 'Print to STDOUT') { |p| options[:print] = p }
471469
}.parse!
472470

manifests/service/bolt.pp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@
1313
Optional[Integer] $metrics_server_port = $puppet_metrics_collector::metrics_server_port,
1414
Optional[String] $metrics_server_db_name = $puppet_metrics_collector::metrics_server_db_name,
1515
) {
16-
<<<<<<< HEAD
17-
puppet_metrics_collector::pe_metric { 'bolt' :
18-
metric_ensure => $metrics_ensure,
19-
cron_minute => "0/${collection_frequency}",
20-
retention_days => $retention_days,
21-
hosts => $hosts,
22-
metrics_port => $port,
23-
additional_metrics => $extra_metrics,
24-
metric_script_file => 'puma_metrics',
25-
metrics_server_type => $metrics_server_type,
26-
metrics_server_hostname => $metrics_server_hostname,
27-
metrics_server_port => $metrics_server_port,
28-
metrics_server_db_name => $metrics_server_db_name,
29-
excludes => $excludes,
30-
=======
3116
puppet_metrics_collector::pe_metric { 'bolt' :
3217
metric_ensure => $metrics_ensure,
3318
cron_minute => "0/${collection_frequency}",
@@ -42,6 +27,5 @@
4227
metrics_server_port => $metrics_server_port,
4328
metrics_server_db_name => $metrics_server_db_name,
4429
excludes => $excludes,
45-
>>>>>>> 67e0950 ((SUP-1969) Reconcile pe_metric parameter differences)
4630
}
4731
}

spec/classes/puppet_metrics_collector_system_spec.rb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@
8080
end
8181

8282
context 'when metrics shipping is enabled' do
83-
let(:params) { {
84-
metrics_server_type: "influxdb",
85-
metrics_server_db_name: "puppet_metrics",
86-
metrics_server_hostname: "influxdb.example"
83+
let(:params) do
84+
{
85+
metrics_server_type: 'influxdb',
86+
metrics_server_db_name: 'puppet_metrics',
87+
metrics_server_hostname: 'influxdb.example'
8788
}
88-
}
89+
end
90+
let(:facts) { { puppet_metrics_collector: { have_sysstat: true, have_systemd: true } } }
8991

90-
it { is_expected.to contain_cron('system_cpu_metrics_collection').with_command(/--influx-db\s+puppet_metrics/) }
92+
it { is_expected.to contain_puppet_metrics_collector__collect('system_cpu').with_metrics_command(%r{--influx-db\s+puppet_metrics}) }
9193
end
9294

9395
context 'when metrics shipping is enabled in puppet_metrics_collector' do
@@ -96,21 +98,24 @@
9698
class {'puppet_metrics_collector':
9799
metrics_server_type => "influxdb",
98100
metrics_server_db_name => "puppet_metrics",
99-
metrics_server_hostname => "influxdb.example"
101+
metrics_server_hostname => "influxdb.example",
100102
}
101103
PRE_COND
102104
end
105+
let(:facts) { { puppet_metrics_collector: { have_sysstat: true, have_systemd: true } } }
103106

104-
it { is_expected.to contain_cron('system_cpu_metrics_collection').with_command(/--influx-db\s+puppet_metrics/) }
107+
it { is_expected.to contain_puppet_metrics_collector__collect('system_cpu').with_metrics_command(%r{--influx-db\s+puppet_metrics}) }
105108
end
106109

107110
context 'when metrics shipping is not enabled' do
108-
let(:params) { {
109-
metrics_server_db_name: "puppet_metrics",
110-
metrics_server_hostname: "influxdb.example"
111+
let(:params) do
112+
{
113+
metrics_server_db_name: 'puppet_metrics',
114+
metrics_server_hostname: 'influxdb.example'
111115
}
112-
}
116+
end
117+
let(:facts) { { puppet_metrics_collector: { have_sysstat: true, have_systemd: true } } }
113118

114-
it { is_expected.not_to contain_cron('system_cpu_metrics_collection').with_command(/--influx-db\s+puppet_metrics/) }
119+
it { is_expected.not_to contain_puppet_metrics_collector__collect('system_cpu').with_metrics_command(%r{--influx-db\s+puppet_metrics}) }
115120
end
116121
end
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
require 'spec_helper'
22

33
describe 'puppet_metrics_collector::generate_metrics_server_command' do
4-
context "when the metrics parameters are undef" do
4+
context 'when the metrics parameters are undef' do
55
it { is_expected.to run.with_params('scripts_dir').and_return('') }
66
end
77

8-
context "when the metrics type is influxdb" do
9-
10-
context "without the port" do
8+
context 'when the metrics type is influxdb' do
9+
context 'without the port' do
1110
it {
1211
is_expected.to run.with_params(
1312
'scripts_dir',
1413
'influxdb',
1514
'metrics_server_hostname',
16-
'metrics_server_db_name'
15+
'metrics_server_db_name',
1716
).and_return(
18-
"--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to influxdb --influx-db metrics_server_db_name -"
19-
)
17+
'--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to influxdb --influx-db metrics_server_db_name -',
18+
)
2019
}
2120
end
2221

23-
context "with the port" do
22+
context 'with the port' do
2423
it {
2524
is_expected.to run.with_params(
2625
'scripts_dir',
2726
'influxdb',
2827
'metrics_server_hostname',
2928
'metrics_server_db_name',
30-
8080
29+
8080,
3130
).and_return(
32-
"--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to influxdb --influx-db metrics_server_db_name --port 8080 -"
31+
'--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to influxdb --influx-db metrics_server_db_name --port 8080 -',
3332
)
3433
}
3534
end
3635

37-
context "without the database name" do
36+
context 'without the database name' do
3837
it { is_expected.to run.with_params('scripts_dir', 'influxdb').and_raise_error(Puppet::ParseError) }
3938
end
4039
end
4140

42-
context "when metrics type is graphite" do
43-
it { is_expected.to run.with_params('scripts_dir', 'graphite', 'metrics_server_hostname').and_return('--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to graphite -') }
41+
context 'when metrics type is graphite' do
42+
it {
43+
is_expected.to run.with_params('scripts_dir', 'graphite',
44+
'metrics_server_hostname').and_return('--print | scripts_dir/json2timeseriesdb --netcat metrics_server_hostname --convert-to graphite -')
45+
}
4446
end
4547

46-
context "when metrics type is splunk_hec" do
48+
context 'when metrics type is splunk_hec' do
4749
it { is_expected.to run.with_params('scripts_dir', 'splunk_hec').and_return('--print | /opt/puppetlabs/bin/puppet splunk_hec --sourcetype puppet:metrics --pe_metrics') }
4850
end
4951
end

0 commit comments

Comments
 (0)