-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Add dpdk_telemetry plugin #913
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Class to manage dpdk_telemetry plugin for collectd. | ||
# | ||
# The dpdk_telemetry plugin collects DPDK ethernet device metrics via | ||
# dpdk_telemetry library. | ||
# | ||
# Plugin retrieves metrics from a DPDK packet forwarding application | ||
# by sending the JSON formatted message via a UNIX domain socket. | ||
# DPDK telemetry component will respond with a JSON formatted reply | ||
# delivering the requested metrics. Plugin parses the JSON data | ||
# and publishes the metric values to collectd for further use. | ||
# | ||
# @param ensure Ensure param for collectd::plugin type. | ||
# @param client_socket_path UNIX domain client socket to receive messages from DPDK telemetry library. | ||
# @param dpdk_socket_path UNIX domain DPDK telemetry socket to be connected to send messages. | ||
# | ||
class collectd::plugin::dpdk_telemetry ( | ||
Enum['present', 'absent'] $ensure = 'present', | ||
Stdlib::Absolutepath $client_socket_path = '/var/run/.client', | ||
Stdlib::Absolutepath $dpdk_socket_path = '/var/run/dpdk/rte/telemetry', | ||
) { | ||
|
||
include collectd | ||
|
||
collectd::plugin { 'dpdk_telemetry': | ||
ensure => $ensure, | ||
content => epp('collectd/plugin/dpdk_telemetry.conf.epp'), | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::dpdk_telemetry', type: :class do | ||
on_supported_os(baseline_os_hash).each do |os, facts| | ||
context "on #{os} " do | ||
let :facts do | ||
facts | ||
end | ||
|
||
options = os_specific_options(facts) | ||
|
||
context ':ensure => present, default params' do | ||
content = <<EOS | ||
# Generated by Puppet | ||
<LoadPlugin dpdk_telemetry> | ||
Globals false | ||
</LoadPlugin> | ||
|
||
<Plugin dpdk_telemetry> | ||
ClientSocketPath "/var/run/.client" | ||
DpdkSocketPath "/var/run/dpdk/rte/telemetry" | ||
</Plugin> | ||
|
||
EOS | ||
|
||
it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_file('dpdk_telemetry.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", | ||
content: content | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
|
||
it "Will not create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_file('dpdk_telemetry.load').with( | ||
ensure: 'absent', | ||
path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => present and :client_socket_path => /test/path/.client' do | ||
let :params do | ||
{ client_socket_path: '/test/path/.client' } | ||
end | ||
|
||
it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_file('dpdk_telemetry.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", | ||
content: %r{ClientSocketPath "/test/path/.client"}m | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => present and :dpdk_socket_path => /test/path/telemetry' do | ||
let :params do | ||
{ dpdk_socket_path: '/test/path/telemetry' } | ||
end | ||
|
||
it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking into creating test case that you described but I stumbled upon obstacle. I wrote following test:
Configuration is generated using specified default values rather than assuming that no value was provided. I'm relatively new to Puppet, RSpec and Ruby so I can't be sure, however my observations suggests that it in fact might work that way. Additionally, I couldn't find this kind of test case in this repository. Are you sure that test case you described is possible to write? If so, could you give any suggestion how to proceed? |
||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_file('dpdk_telemetry.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", | ||
content: %r{DpdkSocketPath "/test/path/telemetry"}m | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Plugin dpdk_telemetry> | ||
<% if $collectd::plugin::dpdk_telemetry::client_socket_path { -%> | ||
ClientSocketPath "<%= $collectd::plugin::dpdk_telemetry::client_socket_path %>" | ||
<% } -%> | ||
<% if $collectd::plugin::dpdk_telemetry::dpdk_socket_path { -%> | ||
DpdkSocketPath "<%= $collectd::plugin::dpdk_telemetry::dpdk_socket_path %>" | ||
<% } -%> | ||
</Plugin> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a context for
ensure => absent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case with "ensure => absent" added.