20150314 - functional testing for configuration management @ cascadia it conference

57
Garrett Honeycutt [email protected] learnpuppet.com @learnpuppet Functional testing for configuration management

Upload: garrett-honeycutt

Post on 17-Jul-2015

131 views

Category:

Technology


0 download

TRANSCRIPT

Garrett [email protected]

learnpuppet.com@learnpuppet

Functional testing for configuration management

spec vs functional

http://www.structuretech1.com/wp-content/uploads/2012/11/Gate-valve-exploded1.jpg

what is functional testing?

Functional test for ntp module

1. set time incorrectly2. apply ntp class3. check that time is correct

#/bin/sh # puppet agent -t while [ $? -ne 0 ] do puppet agent -t done

Functional test for idempotency

1. start with a blank system2. apply class3. changes should occur4. apply class again5. no changes occur

why write tests at

all?

tooling

https://github.com/unixmonkey/learngit

http://serverspec.org/

how to approach

functionally test each module

functionally test each role

role: repo* main entry point is the class

yum::server

role: repo* main entry point is the class

yum::server

* simple apache web server with a DocumentRoot set to serve packages

role: repo* main entry point is the class

yum::server

* simple apache web server with a DocumentRoot set to serve packages

* manages only a couple files and packages

apache hosts rsyslog apache::mod::cache inittab selinux apache::mod::cgi motd ssh apache::mod::dav network sysklogd apache::mod::dav_fs nsswitch timezone apache::mod::default ntp types apache::mod::proxy pam utils apache::mod::ssl pam::accesslogin vim apache::params pam::limits wget common papertrail yum dnsclient puppet::agent yum::server facter redhat yum::updatesd

apache hosts rsyslog apache::mod::cache inittab selinux apache::mod::cgi motd ssh apache::mod::dav network sysklogd apache::mod::dav_fs nsswitch timezone apache::mod::default ntp types apache::mod::proxy pam utils apache::mod::ssl pam::accesslogin vim apache::params pam::limits wget common papertrail yum dnsclient puppet::agent yum::server facter redhat yum::updatesd

36 classes in 23 modules

Monitoring

$ ping -c1 example.com PING example.com (93.184.216.119): 56 data bytes 64 bytes from 93.184.216.119: icmp_seq=0 ttl=58 time=4.947 ms

--- example.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 4.947/4.947/4.947/0.000 ms

$ curl example.com -I HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: max-age=604800 Content-Type: text/html Date: Thu, 13 Nov 2014 03:52:15 GMT Etag: "359670651" Expires: Thu, 20 Nov 2014 03:52:15 GMT Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT Server: ECS (pae/3796) X-Cache: HIT x-ec-custom-error: 1 Content-Length: 1270

1. set the role2. converge on model3. seed a package on the system4. on another system, set it to use the first as a repo5. install the seeded package from the repo

who does what?

how to automate

&&