Skip to Content
Learning Puppet 4
book

Learning Puppet 4

by Jo Rhett
April 2016
Intermediate to advanced
594 pages
12h 53m
English
O'Reilly Media, Inc.
Content preview from Learning Puppet 4

Chapter 17. Testing Modules

Sad to say, but not many modules include good tests. Good tests help keep embarrassing bugs from going out. Tests can save you a lot of time, avoiding the exhaustive debugging of an issue in production that turns out to be a wrong type used, or a similar mistake.

This chapter will teach you how to add good tests to your modules. When I got started, I struggled a lot due to a lack of good examples. This chapter provides good examples of each type of test you should be doing. It’s my intention that you’d be able to use the examples provided here like tinker toys, and build a good set of tests for your modules without much effort.

This chapter won’t provide exhaustive documentation of rspec or beaker, the testing tools of choice for the Puppet ecosystem. However, you should be able to build a good foundation of tests from what we cover in this chapter.

Let’s get started by setting up your testing tools.

Installing Dependencies

The first time you set up to do testing, you’ll need to install some specific software.

Installing Ruby

You can use the Ruby version that comes with your operating system. If you are using the Vagrant testing setup documented in this book, it is easy to install Ruby into the system packages:

[vagrant@client ~]$ sudo yum install -y ruby-devel rubygems rake libxml2-devel

Guides for installing Ruby can be found in Appendix C.

Install the bundler gem for local installation of necessary dependencies:

$ sudo gem install bundler 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro Puppet, Second Edition

Pro Puppet, Second Edition

Spencer Krum, William Van Hevelingen, Ben Kero, James Turnbull, Jeffery McCune
Mastering Puppet 5

Mastering Puppet 5

Ryan Russell-Yates, Jason Southgate

Publisher Resources

ISBN: 9781491907993Purchase bookErrata Page