Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit f64c54f

Browse files
committed
Update spec tests
1 parent eb69584 commit f64c54f

File tree

11 files changed

+29
-37
lines changed

11 files changed

+29
-37
lines changed

data/os/Suse.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
puppet_metrics_dashboard::manage_repos: false
33
puppet_metrics_dashboard::influx_db_service_name: 'influxdb'
4-
puppet_metrics_dashboard::grafana_version: '7.1.4'
54
puppet_metrics_dashboard::influx_archive_source: 'https://dl.influxdata.com/influxdb/releases/influxdb-1.8.1_linux_amd64.tar.gz'
65
puppet_metrics_dashboard::grafana_install_method: 'package'
76
puppet_metrics_dashboard::grafana_manage_repo: false

manifests/init.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@
225225
String $influx_db_password,
226226

227227
String $telegraf_db_name,
228-
Optional[String[1]] $telegraf_db_retention_duration = undef,
229228
String[2] $telegraf_agent_interval,
230229
String[2] $http_response_timeout,
231230
String[2] $pg_query_interval,
@@ -246,15 +245,17 @@
246245
Hash $grafana_config,
247246

248247
Boolean $grafana_manage_repo = $manage_repos,
249-
Optional[Stdlib::Httpsurl] $influx_archive_source = undef,
250-
Optional[Stdlib::Httpsurl] $grafana_archive_source = undef,
251248
Enum['docker', 'archive', 'package', 'repo'] $grafana_install_method = 'repo',
252249

253250
Puppet_metrics_dashboard::HostList $master_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('master'),
254251
Puppet_metrics_dashboard::HostList $puppetdb_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('puppetdb'),
255252
Puppet_metrics_dashboard::HostList $postgres_host_list = puppet_metrics_dashboard::localhost_or_hosts_with_pe_profile('database'),
256253

257254
Puppet_metrics_dashboard::Puppetdb_metric $puppetdb_metrics = puppet_metrics_dashboard::puppetdb_metrics(),
255+
256+
Optional[String[1]] $telegraf_db_retention_duration = undef,
257+
Optional[Stdlib::Httpsurl] $influx_archive_source = undef,
258+
Optional[Stdlib::Httpsurl] $grafana_archive_source = undef,
258259
) {
259260

260261
unless $facts['os']['family'] =~ /^(RedHat|Debian|Suse)$/ {

manifests/post_start_configs.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@
3030
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show databases\' | grep ${db_name}",
3131
require => Exec['create influxdb admin user'],
3232
}
33-
# lint:endignore
3433
}
3534

3635
if $puppet_metrics_dashboard::telegraf_db_retention_duration =~ NotUndef {
37-
exec { "create default telegraf database retention policy":
36+
exec { 'create default telegraf database retention policy':
3837
command => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"CREATE RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name} DURATION ${puppet_metrics_dashboard::telegraf_db_retention_duration} REPLICATION 1 DEFAULT\"",
39-
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
38+
unless => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
4039
require => Exec["create influxdb puppet_metrics database ${puppet_metrics_dashboard::telegraf_db_name}"],
4140
}
4241
} else {
43-
exec { "drop existing retention policy if ever created":
42+
exec { 'drop existing retention policy if ever created':
4443
command => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"DROP RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name}\"",
45-
onlyif => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
44+
onlyif => "influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
4645
}
46+
# lint:endignore
4747
}
4848

4949
$_uri = $puppet_metrics_dashboard::use_dashboard_ssl ? {

manifests/profile/ldap_auth.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
# Set to false if you do not want to skip SSL cert validation. Defaults to true.
1919
#
2020
# @param ldap_bind_dn
21-
# Search user bind dn. If you can provide a single bind expression that matches all possible users, you can skip specifying ldap_bind_password.
21+
# Search user bind dn. If you can provide a single bind expression that matches all possible users,
22+
# you can skip specifying ldap_bind_password.
2223
#
2324
# @param ldap_bind_password
2425
# Search user bind password. If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""

manifests/profile/master/postgres.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
plugin_type => 'postgresql_extensible',
3535
options => [{
3636
'interval' => $query_interval,
37-
'address' => "postgres://telegraf@${postgres_host}:${port}/pe-puppetdb?sslmode=require&sslkey=/etc/telegraf/${trusted['certname']}_key.pem&sslcert=/etc/telegraf/${trusted['certname']}_cert.pem&sslrootcert=/etc/telegraf/ca.pem",
37+
'address' => "postgres://telegraf@${postgres_host}:${port}/pe-puppetdb?sslmode=require&sslkey=/etc/telegraf/${trusted['certname']}_key.pem&sslcert=/etc/telegraf/${trusted['certname']}_cert.pem&sslrootcert=/etc/telegraf/ca.pem", #lint:ignore:140chars
3838
'outputaddress' => $postgres_host,
3939
'databases' => $databases,
4040
'query' => [{
4141
'sqlquery' => 'SELECT * FROM pg_stat_database',
4242
'version' => 901,
4343
'withdbname' => false,
4444
},{
45-
'sqlquery' => 'SELECT relname as s_table, pg_relation_size(relid) as size FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC',
45+
'sqlquery' => 'SELECT relname as s_table, pg_relation_size(relid) as size FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC', #lint:ignore:140chars
4646
'version' => 901,
4747
'withdbname' => false,
4848
'tagvalue' => 's_table',
@@ -52,7 +52,7 @@
5252
'withdbname' => false,
5353
'tagvalue' => 'v_table',
5454
},{
55-
'sqlquery' => 'SELECT relname as io_table, heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit, toast_blks_read, toast_blks_hit, tidx_blks_read, tidx_blks_hit FROM pg_statio_user_tables',
55+
'sqlquery' => 'SELECT relname as io_table, heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit, toast_blks_read, toast_blks_hit, tidx_blks_read, tidx_blks_hit FROM pg_statio_user_tables', #lint:ignore:140chars
5656
'version' => 901,
5757
'withdbname' => false,
5858
'tagvalue' => 'io_table',

manifests/profile/postgres.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# @summary This class is deprecated. Please use the Puppet_metrics_dashboard::Profile::Master::Postgres_access class.
22
#
33
# @param grafana_host
4-
# The FQDN of the host where telegraf runs.
5-
# Defaults to an empty string. You can explicitly set this parameter or the class attempts to lookup which host has the puppet_metrics_dashboard class applied in PuppetDB. If the parameter is not set and the lookup does not return anything we issue a warning.
6-
#
4+
# The FQDN of the host where telegraf runs. Defaults to an empty string.
5+
# You can explicitly set this parameter or the class attempts to lookup which host has the puppet_metrics_dashboard class applied
6+
# in PuppetDB. If the parameter is not set and the lookup does not return anything we issue a warning.
77
class puppet_metrics_dashboard::profile::postgres (
88
String $grafana_host = ''
99
){
1010

11-
fail('The Puppet_metrics_dashboard::Profile::Postgres class is deprecated. Please use the Puppet_metrics_dashboard::Profile::Master::Postgres_access instead.')
11+
fail('Puppet_metrics_dashboard::Profile::Postgres is deprecated in favor of Puppet_metrics_dashboard::Profile::Master::Postgres_access.')
1212

1313
}

manifests/service.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
systemd::unit_file { "${puppet_metrics_dashboard::influx_db_service_name}.service":
1010
source => "puppet:///modules/${module_name}/influxdb.service",
1111
}
12-
service {"${puppet_metrics_dashboard::influx_db_service_name}":
13-
ensure => running,
14-
enable => true,
12+
service {$puppet_metrics_dashboard::influx_db_service_name:
13+
ensure => running,
14+
enable => true,
1515
require => Systemd::Unit_file["${puppet_metrics_dashboard::influx_db_service_name}.service"],
1616
}
1717
}

spec/classes/grafana_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
when 'Suse'
5555
is_expected.to contain_class('grafana')
5656
.with_install_method('package')
57-
.with_manage_package_repo(true)
57+
.with_manage_package_repo(false)
5858
.with_version('8.2.2')
5959
.with_require('Service[influxdb]')
6060
end

spec/classes/init_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
# verify the defualts have not changed
3636
# rubocop:disable RSpec/ExampleWording
3737
it 'should have all the expected default vaulues for parameters' do
38-
case facts[:os]['family']
39-
when 'Suse'
40-
manage_repos = false
41-
else
42-
manage_repos = true
43-
end
38+
manage_repos = case facts[:os]['family']
39+
when 'Suse'
40+
false
41+
else
42+
true
43+
end
4444
is_expected.to contain_class('puppet_metrics_dashboard')
4545
.with_add_dashboard_examples(false)
4646
.with_manage_repos(manage_repos)

spec/classes/post_start_configs_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
describe 'puppet_metrics_dashboard::post_start_configs' do
44
on_supported_os.each do |os, facts|
5-
influx_command = case facts[:os]['family']
6-
when 'Suse'
7-
'/opt/influxdb/usr/bin/influx'
8-
else
9-
'/usr/bin/influx'
10-
end
5+
influx_command = 'influx'
116
context "with facter #{RSpec.configuration.default_facter_version} on #{os}" do
127
let(:node) do
138
'testhost.example.com'

0 commit comments

Comments
 (0)