Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create processes plugin configuration on RedHat #927

Merged
merged 1 commit into from Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions manifests/plugin/processes.pp
Expand Up @@ -21,7 +21,7 @@
interval => $interval,
}

concat { "${collectd::plugin_conf_dir}/processes-config.conf":
concat { "${collectd::plugin_conf_dir}/processes_config.conf":
ensure => $ensure,
mode => $collectd::config_mode,
owner => $collectd::config_owner,
Expand All @@ -32,13 +32,13 @@
concat::fragment { 'collectd_plugin_processes_conf_header':
order => '00',
content => epp('collectd/plugin/processes-header.conf.epp'),
target => "${collectd::plugin_conf_dir}/processes-config.conf",
target => "${collectd::plugin_conf_dir}/processes_config.conf",
}

concat::fragment { 'collectd_plugin_processes_conf_footer':
order => '99',
content => '</Plugin>',
target => "${collectd::plugin_conf_dir}/processes-config.conf",
target => "${collectd::plugin_conf_dir}/processes_config.conf",
}

if $processes {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/processes/process.pp
Expand Up @@ -17,7 +17,7 @@
'collect_file_descriptor' => $collect_file_descriptor,
'collect_memory_maps' => $collect_memory_maps,
}),
target => "${collectd::plugin_conf_dir}/processes-config.conf",
target => "${collectd::plugin_conf_dir}/processes_config.conf",
}

}
2 changes: 1 addition & 1 deletion manifests/plugin/processes/processmatch.pp
Expand Up @@ -19,6 +19,6 @@
'collect_file_descriptor' => $collect_file_descriptor,
'collect_memory_maps' => $collect_memory_maps,
}),
target => "${collectd::plugin_conf_dir}/processes-config.conf",
target => "${collectd::plugin_conf_dir}/processes_config.conf",
}
}
48 changes: 48 additions & 0 deletions spec/acceptance/define_plugin_processes_process_spec.rb
@@ -0,0 +1,48 @@
require 'spec_helper_acceptance'

describe 'collectd::plugin::processes::process' do
context 'basic parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
pp = <<-EOS
class{'collectd':
utils => true,
purge => true,
recurse => true,
purge_config => true,
}

collectd::plugin::processes::process{'bar':
collect_file_descriptor => true,
}

# Configure one write plugin to keep logs quiet
class{'collectd::plugin::csv':}
# Create a socket to query
class{'collectd::plugin::unixsock':
socketfile => '/var/run/collectd-sock',
socketgroup => 'root',
deletesocket => true,
}

EOS
# Run 3 times since the collectd_version
# fact is impossible until collectd is
# installed.
apply_manifest(pp, catch_failures: false)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Wait to get some data
shell('sleep 10')
end

describe service('collectd') do
it { is_expected.to be_running }
end

describe command('collectdctl -s /var/run/collectd-sock listval') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{processes-bar/ps_count} }
end
end
end
50 changes: 50 additions & 0 deletions spec/acceptance/define_plugin_processes_processmatch_spec.rb
@@ -0,0 +1,50 @@
require 'spec_helper_acceptance'

describe 'collectd::plugin::processes::processmatchs' do
context 'basic parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
pp = <<-EOS
class{'collectd':
utils => true,
purge => true,
recurse => true,
purge_config => true,

}

# Configure one write plugin to keep logs quiet
collectd::plugin::processes::processmatch{'foo':
collect_file_descriptor => true,
regex => 'foo .*$',
}

class{'collectd::plugin::csv':}
# Create a socket to query
class{'collectd::plugin::unixsock':
socketfile => '/var/run/collectd-sock',
socketgroup => 'root',
deletesocket => true,
}

EOS
# Run 3 times since the collectd_version
# fact is impossible until collectd is
# installed.
apply_manifest(pp, catch_failures: false)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Wait to get some data
shell('sleep 10')
end

describe service('collectd') do
it { is_expected.to be_running }
end

describe command('collectdctl -s /var/run/collectd-sock listval') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{processes-foo/ps_count} }
end
end
end
34 changes: 19 additions & 15 deletions spec/classes/collectd_plugin_processes_spec.rb
Expand Up @@ -18,19 +18,19 @@
)
end

it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do
is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes-config.conf").that_requires('File[collectd.d]')
it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do
is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes_config.conf").that_requires('File[collectd.d]')
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_header').with(
content: "<Plugin processes>\n",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '00'
)
end

it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do
it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_footer').with(
content: %r{</Plugin>},
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '99'
)
end
Expand Down Expand Up @@ -66,15 +66,15 @@
}
end

it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do
is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes-config.conf").that_requires('File[collectd.d]')
it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do
is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes_config.conf").that_requires('File[collectd.d]')
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_header').with(
content: "<Plugin processes>
CollectContextSwitch true
CollectFileDescriptor false
CollectMemoryMaps true
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '00'
)
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_httpd').with(
Expand All @@ -84,14 +84,14 @@
CollectMemoryMaps false
</Process>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '50'
)
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_mysql').with(
content: " <Process \"mysql\">
</Process>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '50'
)

Expand All @@ -102,14 +102,14 @@
CollectMemoryMaps false
</ProcessMatch>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '51'
)
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_processmatch_dove').with(
content: " <ProcessMatch \"dove\" \"dove.*\">
</ProcessMatch>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '51'
)
end
Expand All @@ -122,19 +122,19 @@
}
end

it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do
it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_process1').with(
content: " <Process \"process1\">
</Process>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '50'
)
is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_process2').with(
content: " <Process \"process2\">
</Process>
",
target: "#{options[:plugin_conf_dir]}/processes-config.conf",
target: "#{options[:plugin_conf_dir]}/processes_config.conf",
order: '50'
)
end
Expand All @@ -145,6 +145,10 @@
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_processes.load').with_ensure('absent')
is_expected.to contain_file('package_processes.load').with_path('/etc/collectd.d/processes-config.conf')
end
it 'Will not clash with package file' do
is_expected.not_to contain_concat('/etc/collectd.d/processes-config.conf')
end
end
end
Expand Down