Puppet Module spec testing

110 views
Skip to first unread message

Peter Berghold

unread,
Aug 4, 2015, 3:37:18 PM8/4/15
to puppet-users
Is there a newer set of documents on doing Spec testing of Puppet modules than this link?  

I am running into a brick wall getting this to work so I have to assume I'm doing something wrong...

Martin Alfke

unread,
Aug 5, 2015, 3:38:51 AM8/5/15
to puppet...@googlegroups.com
Hi Peter,
On 04 Aug 2015, at 21:37, Peter Berghold <salty....@gmail.com> wrote:

> Is there a newer set of documents on doing Spec testing of Puppet modules than this link?
> https://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing
>
> I am running into a brick wall getting this to work so I have to assume I'm doing something wrong…

This should still be valid documentation.
It only refers to unit testing.
For acceptance testing you should take a look on beaker.

hth,
Martin

Gareth Rushgrove

unread,
Aug 5, 2015, 3:51:45 AM8/5/15
to puppet...@googlegroups.com
If you could post a test case I'd be happy to take a look.

My experience is starting from a working example is useful, shameless
self promotion I know but, the puppet module skeleton should run a set
of unit tests out of the box:
https://github.com/garethr/puppet-module-skeleton

Even if you don't use the skeleton you should be able to get the tests
running at least and then port to your own module.

Gareth


> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAArvnv14GJ0v6Ef0rS4KAcrOf1C%3DUiu%3DpM%2BsnJcxjsptqeipCQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Gareth Rushgrove
@garethr

devopsweekly.com
morethanseven.net
garethrushgrove.com

Tehmasp Chaudhri

unread,
Aug 5, 2015, 10:49:57 AM8/5/15
to Puppet Users
I've got something similar I built a while ago (and need to update again since I'm back in the Puppet world).


It will help you create a new module dir with a bunch of puppet tools setup for you - including rspec-puppet for spec testing and serverspec for integration spec testing w/ virtualbox/vagrant.

Garrett Honeycutt

unread,
Aug 5, 2015, 12:44:30 PM8/5/15
to puppet...@googlegroups.com
Hi Peter,

Take a look at the spec tests[1] in my vim module. It shows how to test
for multiple OS's and how to handle parameters and their validation. The
module itself is simple in that it only handles three resources and a
handful of parameters.

Here's a link[2] to a tutorial I gave last year at LOADays in Antwerp.
This[3] is the vagrant environment we used, though I'm not confident
that it will still work today without some tweaks.

[1] -
https://github.com/ghoneycutt/puppet-module-vim/blob/master/spec/classes/init_spec.rb

[2] - http://www.slideshare.net/gh/20140406-loa-daystddwithpuppettutorial

[3] - https://github.com/ghoneycutt/learnpuppet-tdd-vagrant

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Ilja Bobkevic

unread,
Aug 28, 2015, 7:00:35 AM8/28/15
to Puppet Users
Hi,

You're welcome to checkout our modules as well at https://github.com/unibet/. For instance https://github.com/unibet/puppet-vagrant.

Some details about our testing mechanics:
5. Travis is set to release modules automatically if tests are passing. See https://github.com/unibet/puppet-vagrant/blob/master/.travis.yml

Usual command sequence is:
1. git clone
2. bundle install
3. Make changes
4. rake # no arguments = default task = spec and lint
5. kitchen test # no arguments = all suites
6. commit/push

Let me know if you have any questions.

// Ilja

Walid

unread,
Nov 18, 2015, 12:42:52 PM11/18/15
to puppet...@googlegroups.com
Hi Ilja,

Any reason you went with test-kitchen as opposed to beaker? i am trying to find a comparision between the two and where one fits better?  as i am going to work with Ansible too i see that learning one tool that would work both in Ansible, and Puppet is a plus, however i am interested to know if one is testing Puppet environments only what are merits and cons of test-kitchen vs. Beaker, given that beaker seems to have matured more since the last year, our toolset will involve bare-metal "ssh", vagrant/libvirt, and docker.

Best regards,

Walid 

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages