This document discusses testing Puppet code. It begins by explaining why testing Puppet is important due to the large amount of Puppet code and its use across many platforms. It then provides an overview of existing Puppet testing tools like puppet-lint, rspec-puppet, and beaker-rspec. It notes different types of Puppet users have varying needs and experiences with testing. Key challenges discussed are improving the getting started experience, adopting acceptance testing more widely, providing consistent interfaces, and addressing the Ruby dependency of many tools. The document concludes that the community has powerful tools but needs more consistent user experiences and workflows to help beginners test Puppet code.
15. Note that this just represents public
code on GitHub. Lots of private Puppet
code out there too
Gareth Rushgrove
16. (without introducing more risk)
Gareth Rushgrove
How many .pp files on GitHub?
SELECT COUNT(*)
FROM [puppet.puppet_files]
-- 489725
17. (without introducing more risk)
Gareth Rushgrove
How many lines of Puppet code?
SELECT
COUNT(line) total_lines
FROM (
SELECT SPLIT(content, 'n') AS line
FROM [puppet.puppet_content]
)
-- 6697099
18. (without introducing more risk)
Gareth Rushgrove
How big are .pp files?
SELECT QUANTILES(total_lines, 10) AS q
FROM (
SELECT
COUNT(line) total_lines
FROM (
SELECT SPLIT(content, 'n') AS line, id
FROM [puppet.puppet_content]
)
GROUP BY id
)
19. 50% of Puppet files are 20 lines or less.
90% of Puppet files are 100 lines or less
Gareth Rushgrove
20. The largest Puppet file public on GitHub
has 25,238 lines
Gareth Rushgrove
32. (without introducing more risk)
Gareth Rushgrove
Style conformance
$ puppet-lint /etc/puppet/modules
foo/manifests/bar.pp - ERROR: trailing whitespace found on li
apache/manifests/server.pp - WARNING: variable not enclosed i
...
34. (without introducing more risk)
Gareth Rushgrove
Unit tests for Puppet
it { is_expected.to compile }
it { is_expected.to contain_class('db') }
it do
is_expected.to contain_package('mysql-server')
.with_ensure('present')
end
it { is_expected.to have_exec_resource_count(0) }
36. (without introducing more risk)
Gareth Rushgrove
Popular Puppet gems
SELECT package, COUNT(*) count
FROM (
SELECT REGEXP_EXTRACT(line, r'gem ['|"](.*)['|"]') packag
FROM (
SELECT SPLIT(content, 'n') line, id
FROM [puppet.gemfile_contents]
WHERE content CONTAINS 'gem' )
GROUP BY package, id
)
GROUP BY 1
ORDER BY count DESC
LIMIT 30;
75. 60% of respondents described
themselves as Puppet power users
Gareth Rushgrove
76. Only 12% of respondents described
themselves as Ruby power users. A
third of those work for Puppet!
Gareth Rushgrove
77. - More help with using Ruby for testing?
- Support for testing in other languages?
- Native Puppet support for testing?
- Containerised testing abstraction?
Gareth Rushgrove