How to run tests on custom report parser

35 views
Skip to first unread message

tracyde

unread,
Nov 4, 2014, 9:32:11 AM11/4/14
to puppe...@googlegroups.com
I am new to ruby development and want to integrate my report parser with TravisCI. I have read articles and blog posts on how to integrate Puppet modules with rspec, puppet-lint, and travisci but those are not directly applicable to modules that do nothing but provide lib instances (facts, report parsers, etc.)

Here is a link to my code on github https://github.com/tracyde/puppet-influxdb-reporter and my puppet forge link https://forge.puppetlabs.com/tracyde/influxdb_reporter

The module submits metrics from puppet reports to an InfluxDB database.

Gareth Rushgrove

unread,
Nov 4, 2014, 12:46:14 PM11/4/14
to puppe...@googlegroups.com
Good idea, I'm also pretty interested in InfluxDB.

Regarding testing things in lib, ultimately it's just ruby code which
is good and bad, in that any rspec tutorial will be useful, but bad in
the sense that most won't be specific to Puppet.

Hopefully the following is useful. This is a small module of mine
(alas not a report processor) that has a test suite:

https://github.com/garethr/garethr-digitalocean/tree/master/spec/unit

If the InfluxDB client is using HTTP then you can likely do something
similar to this with webmock.

Gareth

> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-dev+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/7856672a-bbde-4a4b-af41-99d49f50d4ab%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Gareth Rushgrove
@garethr

devopsweekly.com
morethanseven.net
garethrushgrove.com

Wil Cooley

unread,
Nov 7, 2014, 12:00:28 PM11/7/14
to puppet-dev group


On Nov 4, 2014 6:32 AM, "tracyde" <tra...@gmail.com> wrote:
>
> I am new to ruby development and want to integrate my report parser with TravisCI. I have read articles and blog posts on how to integrate Puppet modules with rspec, puppet-lint, and travisci but those are not directly applicable to modules that do nothing but provide lib instances (facts, report parsers, etc.)
>

Alas, I have had my eye out for documentation or utilities for testing report processors for a while and have seen nothing.  For that matter, even figuring out what the incoming data looked like room a bit of digging -- I just read the YAML dump of a 'store' report and assumed I knew what values meant.

My guess is that testing would involve one or more store report YAML files and just enough framework to deserialize that and pass the resulting data to your report processor.

Then you'd need to stub the objects & methods your processor calls for output.

I'm not sure you'd actually need rspec-puppet -- I don't think it provides any facilities that would be useful in this case.

Wil

Wil

Reply all
Reply to author
Forward
0 new messages