Your SlideShare is downloading. ×
0
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Portland PUG April 2014: Beaker 101: Acceptance Test Everything

759

Published on

"Beaker 101: Acceptance Test Everything" presented by Alice Nodelman at the Portland Puppet User Group on April 7, 2014

"Beaker 101: Acceptance Test Everything" presented by Alice Nodelman at the Portland Puppet User Group on April 7, 2014

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
759
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Beaker 101 Acceptance Test Everything
  • 2. Introductions I’m Alice Nodelman, I create automation tools. alice@puppetlabs.com anode on freenode irc (#puppet-dev)
  • 3. What is Beaker? • A black box acceptance testing tool. • Provisions, configures and manages hosts under test. • Executes test files written in Ruby with Beaker DSL functions and procedures.
  • 4. DSL? Domain-specific Language The Beaker DSL is an extension to Ruby for PuppetLabs specific testing steps. Test files have access to all of Ruby plus these additional functions & procedures.
  • 5. Get Beaker Requires Ruby 1.8+ $ gem install beaker $ beaker --help
  • 6. The Workflow 1. Provision hosts for testing 2. Validate & configure test hosts 3. Run provided test files on hosts 4. Report test results 5. Teardown test hosts
  • 7. Command Line Basics • --hosts file o to describe your test hosts • --log-level debug o for more messaging • --preserve-hosts [mode] o policy for cleaning up hosts post-testing o one of always, onfail, never • --no-provision o use hosts that are already up and ready • --parse-only o read all parameters, environment variables and config options and report the final Beaker configuration
  • 8. Master Agent 1 Agent 2 Agent 3 $ beaker --hosts nodes.cfg <...> Creates
  • 9. Master Agent 1 Agent 2 Agent 3 $ beaker --hosts nodes.cfg --preserve-hosts always <...> $ beaker --hosts nodes.cfg --preserve-hosts always --no-provision <...> $ < continued development > $ < done with test hosts, throw away and rebuild from snapshot > Creates Re-uses Start Over
  • 10. Supported Test Host Providers • Vagrant • Google Compute Engine • Amazon EC2 • VMware Fusion • vSphere • vCloud • Solaris Zones • Docker (coming soon!) • OpenStack (coming soon!)
  • 11. HOSTS: ubuntu-10-04-4-x64-master: roles: - master - agent - dashboard - database platform: ubuntu-10.04-amd64 hypervisor : vagrant box: ubuntu-server-10044-x64-vbox4210 box_url : http://boxes/ubuntu-server-10044-x64-vbox4210.box ubuntu-10-04-4-x64-agent: roles: - agent platform: ubuntu-10.04-amd64 hypervisor : vagrant box: ubuntu-server-10044-x64-vbox4210 box_url : http://boxes/ubuntu-server-10044-x64-vbox4210.box CONFIG: pe_ver : 3.1.1 pe_dir : https://buildsarehere/pe-builds/released/3.1.1
  • 12. HOSTS: centos-6-master: roles: - master - agent - database - dashboard platform: el-6-x86_64 image: centos-6-x86_64 hypervisor: google debian-7-agent: roles: - agent platform: debian-7-amd64 image: debian-7-wheezy hypervisor: google CONFIG: gce_project : beaker-compute-api-integration gce_keyfile : /Users/user/privatekey.p12 gce_password: notasecret gce_email : 73f51fpni@developer.gserviceaccount.com pe_dir : https://buildsarehere/pe-builds/released/3.1.1 pe_ver : 3.1.1
  • 13. Roles, what are they? • master, agent, dashboard, database, default • user defined! Provide shortcuts to access machines that have particular responsibilities.
  • 14. Beaker DSL - your helpful friend • Installation o install_pe, upgrade_pe, install_puppet • File o scp_to, scp_from • Command execution o on, shell, puppet, facter, hiera, fact_on • Lots more!
  • 15. Let’s look at tests! test_name “my test” step “first, say hello everywhere” hosts.each do | host | on host, “echo hello” end step “second, say hello on the master” result = on master, “echo hello” step “third, check our command output” assert_equal(result.stdout, “hello”)
  • 16. test_name "/etc/init.d/pe-mcollective restart check" confine :except, :platform => 'solaris' confine :except, :platform => 'windows' confine :except, :platform => 'aix' step "Make sure the service restarts properly" hosts.each do |host| # Commands to execute on the target system. restart_command = "bash -c [[ -x /etc/init.d/pe-mcollective ]] && /etc/init.d/pe- mcollective restart'" process_count_check = "bash -c '[[ $(ps auxww | grep [m]collectived | wc -l) -eq 1 ]]'" # Restart once on(host, restart_command) { assert_equal(0, exit_code) } # Restart again on(host, restart_command) { assert_equal(0, exit_code) } # Check to make sure only one process is running on(host, process_count_check) { assert_equal(0, exit_code) } end
  • 17. Coming up Next - more hypervisors! - a ‘pooling api’ to sit between Beaker and the cloud - creation of a ‘best practices’ guide - more and better documentation
  • 18. What we haven’t talked about beaker-RSpec • A shim between RSpec and Beaker that allows for Rspec-style test construction with full access to the Beaker DSL • Used for Puppet module testing • Listen to Hunter, he knows more
  • 19. Documentation Beaker code • https://github.com/puppetlabs/beaker Beaker Documentation • https://github.com/puppetlabs/beaker/wiki File a Bug • https://github.com/puppetlabs/beaker/issues Beaker DSL • http://rdoc.info/github/puppetlabs/beaker/master/Beaker/DSL

×