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

Add dpdk_telemetry plugin #913

Merged
merged 1 commit into from Mar 4, 2020

Conversation

prabiegx
Copy link
Contributor

The dpdk_telemetry plugin collects DPDK ethernet device metrics via dpdk_telemetry library.

#
class collectd::plugin::dpdk_telemetry (
Enum['present', 'absent'] $ensure = 'present',
Optional[String] $client_socket_path = '/var/run/.client',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Optional[Stdlib::Absolutepath] instead as this value is either undef or a path to a file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's an Optional[] datatype, the default value has to be undef. If you want to pass a default path, like /var/run/.client, it doesn't need to be Optional[] because you cannot pass undef to it. Same applies for $dpdk_socket_path

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value could be, but does not have to be undef. Since the value is either undef or a path to a file, then Stdlib::Absolutepath makes more sense than String.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed String to Stdlib:Absolutepath and kept "Optional[...]" Is that all right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghoneycutt if you pass undef to a variable that has a default value, undef won't overwrite it. In my opinion the Optional[] needs to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed Optional[] since, as @bastelfreak mentioned, we can't change it back to undef if we already have defined default value. Without Optional[] there is now no need for *_socket_path => undef test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghoneycutt are you satisfied with applied modifications?

end
end

context ':ensure => present and :dpdk_socket_path => /test/path/telemetry' do
Copy link
Member

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

Copy link
Contributor Author

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.

{ dpdk_socket_path: '/test/path/telemetry' }
end

it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since client_socket_path can be undef, there should be a test that shows the content when the param is undef. Same for dpdk_socket_path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:

      context ':ensure => present, :client_socket_path => undef and :dpdk_socket_path => undef' do
        let :params do
          { client_socket_path: :undef,
            dpdk_socket_path: :undef }
        end

        sth = <<EOS
# Generated by Puppet
<LoadPlugin dpdk_telemetry>
  Globals false
</LoadPlugin>

<Plugin dpdk_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: sth
          )
        end
      end

Configuration is generated using specified default values rather than assuming that no value was provided.
I found interesting message by jcbollinger here, suggesting that assigning undef doesn't actually assign undef, only implies that no specified value is being assigned, and therefore default should be used.

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?

@ghoneycutt
Copy link
Member

Thanks for the great contribution!

@bastelfreak bastelfreak added enhancement New feature or request needs-work not ready to merge just yet labels Feb 18, 2020
@vox-pupuli-tasks
Copy link

Dear @prabiegx, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@vox-pupuli-tasks
Copy link

Dear @prabiegx, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

1 similar comment
@vox-pupuli-tasks
Copy link

Dear @prabiegx, thanks for the PR!

This is pccibot, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@prabiegx
Copy link
Contributor Author

Changes squashed and rebased.

@prabiegx
Copy link
Contributor Author

prabiegx commented Mar 4, 2020

Is this ready for merge or needs further changes?

@bastelfreak bastelfreak removed the needs-work not ready to merge just yet label Mar 4, 2020
@bastelfreak
Copy link
Member

Thanks for the PR @prabiegx !

@bastelfreak bastelfreak merged commit 6d74352 into voxpupuli:master Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants