O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
Hart Hoover
Making Test-Driven Development
[Somewhat] Bearable on OpenStack
@hhoover
#rackstackatl
#rackstackatl
RACKSPACE VISION
To be recognized as 

one of the world’s great 

service companies.
#rackstackatl
WELL TESTED = GOOD SERVICE
#rackstackatl
TEST-DRIVEN DEVELOPMENT (TRADITIONAL)
Test-driven development is a software development process that relies
...
#rackstackatl
PLAN CODE BUILD TEST RELEASE DEPLOY OPS
THIS IS NOT TDD
THIS IS NOT “DEVOPS”
#rackstackatl
PLAN CODE BUILD TEST RELEASE DEPLOY OPS
TEST
THAT’S A BIT BETTER
(STILL NOT “DEVOPS”)
#rackstackatl
TESTING IS A GOOD IDEA
FIND MISTAKES
BEFORE
THEY HAPPEN
#rackstackatl
TESTING IS A GOOD IDEA
YOUR TEAM
WON’T HATE
YOU
#rackstackatl
TESTING IS A GOOD IDEA
YOUR
CUSTOMERS
WON’T HATE
YOU
#rackstackatl
THE PROBLEM…
#rackstackatl
Object Placeholder
HERO CULTURE
#rackstackatl
LAZINESS OR ARROGANCE
“I just want to write code, not tests.”
“My code works when I push it.”
“It works on m...
#rackstackatl
LEADERSHIP PRESSURE
#rackstackatl
TIME IS MONEY
DEV TIME IS A LOT OF
MONEY
&
#rackstackatl
ONE SOLUTION:
BE THE CHANGE YOU WANT
TO SEE IN THE WORLD
#rackstackatl
ANOTHER SOLUTION:
CONTINUOUS TESTING
#rackstackatl
TOOLS OF THE TRADE…
#rackstackatl
http://hart.io
#rackstackatl
#rackstackatl
#rackstackatl
#rackstackatl
DEPLOY A CHEF SERVER WITH HEAT
https://github.com/rackspace-orchestration-templates/chef-server
#rackstackatl
CHEF DEVELOPMENT KIT
http://www.getchef.com/downloads/chef-dk/
#rackstackatl
chef
CHEF DEVELOPMENT KIT: CLI TOOLS
knife
chef-­‐client
Chef Zero
Ohai
#rackstackatl
CHEF DEVELOPMENT KIT
#rackstackatl
CHEF DEVELOPMENT KIT - BERKSHELF
source	
  ‘https://api.berkshelf.com'	
  
metadata	
  
!
cookbook	
  ‘apt’,...
#rackstackatl
CHEF DEVELOPMENT KIT - BERKSHELF
source	
  ‘https://api.berkshelf.com'	
  
metadata	
  
!
cookbook	
  ‘apt’,...
#rackstackatl
CHEF DEVELOPMENT KIT - BERKSHELF
source	
  ‘https://api.berkshelf.com'	
  
metadata	
  
!
cookbook	
  ‘apt’,...
#rackstackatl
CHEF DEVELOPMENT KIT - BERKSHELF
source	
  ‘https://api.berkshelf.com'	
  
metadata	
  
!
cookbook	
  ‘apt’,...
#rackstackatl
CHEF DEVELOPMENT KIT - BERKSHELF
source	
  ‘https://api.berkshelf.com'	
  
metadata	
  
!
cookbook	
  ‘apt’,...
#rackstackatl
kitchen.ci/docs/guide
CHEF DEVELOPMENT KIT
Test Kitchen
#rackstackatl
-­‐-­‐-­‐	
  
provisioner:	
  
	
  	
  name:	
  chef_solo	
  
!
platforms:	
  
	
  	
  -­‐	
  name:	
  ubunt...
#rackstackatl
-­‐-­‐-­‐	
  
provisioner:	
  
	
  	
  name:	
  chef_solo	
  
!
platforms:	
  
	
  	
  -­‐	
  name:	
  ubunt...
#rackstackatl
-­‐-­‐-­‐	
  
provisioner:	
  
	
  	
  name:	
  chef_solo	
  
!
platforms:	
  
	
  	
  -­‐	
  name:	
  ubunt...
#rackstackatl
-­‐-­‐-­‐	
  
provisioner:	
  
	
  	
  name:	
  chef_solo	
  
!
platforms:	
  
	
  	
  -­‐	
  name:	
  ubunt...
#rackstackatl
-­‐-­‐-­‐	
  
provisioner:	
  
	
  	
  name:	
  chef_solo	
  
!
platforms:	
  
	
  	
  -­‐	
  name:	
  ubunt...
#rackstackatl
CHEF DEVELOPMENT KIT
#rackstackatl
CHEF DEVELOPMENT KIT
ChefSpec
• Built on RSpec
• Converges a Chef run in memory
• Overrides all providers to...
#rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
https://github.com/sethvargo/chefspec/tree/master/examples
#rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require	
  'chefspec'	
  
!
describe	
  'apt_package::install'	
  do	
  
	
  ...
#rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require	
  'chefspec'	
  
!
describe	
  'apt_package::install'	
  do	
  
	
  ...
#rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require	
  'chefspec'	
  
!
describe	
  'apt_package::install'	
  do	
  
	
  ...
#rackstackatl
HONORABLE MENTIONS
#rackstackatl
SERVERSPEC
• Built on RSpec
• Uses SSH to test your servers’ state
#rackstackatl
SERVERSPEC
describe	
  package('httpd')	
  do	
  
	
  	
  it	
  {	
  should	
  be_installed	
  }	
  
end	
  ...
#rackstackatl
meez
https://github.com/paulczar/meez
#rackstackatl
RUBOCOP: STYLE
RUBY STYLE GUIDE
• code layout
• strings
• syntax
• regex
• more
#rackstackatl
GUARD: TEST WHILE YOU WORK
#rackstackatl
#rackstackatl
source	
  'https://rubygems.org'	
  
!
gem	
  'berkshelf'	
  
gem	
  'chef'	
  
gem	
  'meez'	
  
gem	
  'gu...
#rackstackatl
GET TO THE OPENSTACK STUFF
#rackstackatl
source	
  'https://rubygems.org'	
  
!
gem	
  'berkshelf'	
  
gem	
  'chef'	
  
gem	
  'meez'	
  
gem	
  'gu...
#rackstackatl
DEMO TIME!
#rackstackatl54
#rackstackatl55
#rackstackatl
162.242.253.111
LET’S PLAY ON THE CLOUD
#rackstackatl
WE’RE HIRING
http://rackertalent.com
#rackstackatl
RACKSPACE® HOSTING | 5000 WALZEM ROAD | SAN ANTONIO, TX 78218
US SALES: 1-800-961-2888 | US SUPPORT: 1-800-9...
Próximos SlideShares
Carregando em…5
×

Making TDD [Somewhat] Bearable on OpenStack

1.079 visualizações

Publicada em

OpenStack Summit May 2014

Publicada em: Tecnologia, Diversão e humor
  • Seja o primeiro a comentar

Making TDD [Somewhat] Bearable on OpenStack

  1. 1. Hart Hoover Making Test-Driven Development [Somewhat] Bearable on OpenStack @hhoover #rackstackatl
  2. 2. #rackstackatl RACKSPACE VISION To be recognized as 
 one of the world’s great 
 service companies.
  3. 3. #rackstackatl WELL TESTED = GOOD SERVICE
  4. 4. #rackstackatl TEST-DRIVEN DEVELOPMENT (TRADITIONAL) Test-driven development is a software development process that relies on the repetition of a very short development cycle. First the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, then finally refactors the new code to acceptable standards.
  5. 5. #rackstackatl PLAN CODE BUILD TEST RELEASE DEPLOY OPS THIS IS NOT TDD THIS IS NOT “DEVOPS”
  6. 6. #rackstackatl PLAN CODE BUILD TEST RELEASE DEPLOY OPS TEST THAT’S A BIT BETTER (STILL NOT “DEVOPS”)
  7. 7. #rackstackatl TESTING IS A GOOD IDEA FIND MISTAKES BEFORE THEY HAPPEN
  8. 8. #rackstackatl TESTING IS A GOOD IDEA YOUR TEAM WON’T HATE YOU
  9. 9. #rackstackatl TESTING IS A GOOD IDEA YOUR CUSTOMERS WON’T HATE YOU
  10. 10. #rackstackatl THE PROBLEM…
  11. 11. #rackstackatl Object Placeholder HERO CULTURE
  12. 12. #rackstackatl LAZINESS OR ARROGANCE “I just want to write code, not tests.” “My code works when I push it.” “It works on my machine.” “QA does the tests.”
  13. 13. #rackstackatl LEADERSHIP PRESSURE
  14. 14. #rackstackatl TIME IS MONEY DEV TIME IS A LOT OF MONEY &
  15. 15. #rackstackatl ONE SOLUTION: BE THE CHANGE YOU WANT TO SEE IN THE WORLD
  16. 16. #rackstackatl ANOTHER SOLUTION: CONTINUOUS TESTING
  17. 17. #rackstackatl TOOLS OF THE TRADE…
  18. 18. #rackstackatl http://hart.io
  19. 19. #rackstackatl
  20. 20. #rackstackatl
  21. 21. #rackstackatl
  22. 22. #rackstackatl DEPLOY A CHEF SERVER WITH HEAT https://github.com/rackspace-orchestration-templates/chef-server
  23. 23. #rackstackatl CHEF DEVELOPMENT KIT http://www.getchef.com/downloads/chef-dk/
  24. 24. #rackstackatl chef CHEF DEVELOPMENT KIT: CLI TOOLS knife chef-­‐client Chef Zero Ohai
  25. 25. #rackstackatl CHEF DEVELOPMENT KIT
  26. 26. #rackstackatl CHEF DEVELOPMENT KIT - BERKSHELF source  ‘https://api.berkshelf.com'   metadata   ! cookbook  ‘apt’,  ‘~>  2.0’   cookbook  ‘minitest-­‐handler’   cookbook  ‘yum’,  ‘~>  2.0’   cookbook  ‘build-­‐essential’,  github:  ‘opscode-­‐cookbooks/build-­‐essential’   cookbook  ‘mysql_test’,  :path  =>  ‘test/cookbooks/mysql_test’
  27. 27. #rackstackatl CHEF DEVELOPMENT KIT - BERKSHELF source  ‘https://api.berkshelf.com'   metadata   ! cookbook  ‘apt’,  ‘~>  2.0’   cookbook  ‘minitest-­‐handler’   cookbook  ‘yum’,  ‘~>  2.0’   cookbook  ‘build-­‐essential’,  github:  ‘opscode-­‐cookbooks/build-­‐essential’   cookbook  ‘mysql_test’,  :path  =>  ‘test/cookbooks/mysql_test’
  28. 28. #rackstackatl CHEF DEVELOPMENT KIT - BERKSHELF source  ‘https://api.berkshelf.com'   metadata   ! cookbook  ‘apt’,  ‘~>  2.0’   cookbook  ‘minitest-­‐handler’   cookbook  ‘yum’,  ‘~>  2.0’   cookbook  ‘build-­‐essential’,  github:  ‘opscode-­‐cookbooks/build-­‐essential’   cookbook  ‘mysql_test’,  :path  =>  ‘test/cookbooks/mysql_test’
  29. 29. #rackstackatl CHEF DEVELOPMENT KIT - BERKSHELF source  ‘https://api.berkshelf.com'   metadata   ! cookbook  ‘apt’,  ‘~>  2.0’   cookbook  ‘minitest-­‐handler’   cookbook  ‘yum’,  ‘~>  2.0’   cookbook  ‘build-­‐essential’,  github:  ‘opscode-­‐cookbooks/build-­‐essential’   cookbook  ‘mysql_test’,  :path  =>  ‘test/cookbooks/mysql_test’
  30. 30. #rackstackatl CHEF DEVELOPMENT KIT - BERKSHELF source  ‘https://api.berkshelf.com'   metadata   ! cookbook  ‘apt’,  ‘~>  2.0’   cookbook  ‘minitest-­‐handler’   cookbook  ‘yum’,  ‘~>  2.0’   cookbook  ‘build-­‐essential’,  github:  ‘opscode-­‐cookbooks/build-­‐essential’   cookbook  ‘mysql_test’,  :path  =>  ‘test/cookbooks/mysql_test’
  31. 31. #rackstackatl kitchen.ci/docs/guide CHEF DEVELOPMENT KIT Test Kitchen
  32. 32. #rackstackatl -­‐-­‐-­‐   provisioner:      name:  chef_solo   ! platforms:      -­‐  name:  ubuntu-­‐14.04   ! driver:      name:  rackspace      rackspace_region:  IAD      server_name:  rackspace-­‐ubuntu1404      image_id:  bb02b1a3-­‐bc77-­‐4d17-­‐ab5b-­‐421d89850fca      flavor_id:  performance1-­‐1      require_chef_omnibus:  latest   ! suites:      -­‐  name:  default          run_list:  recipe[cookbook::default]          attributes:
  33. 33. #rackstackatl -­‐-­‐-­‐   provisioner:      name:  chef_solo   ! platforms:      -­‐  name:  ubuntu-­‐14.04   ! driver:      name:  rackspace      rackspace_region:  IAD      server_name:  rackspace-­‐ubuntu1404      image_id:  bb02b1a3-­‐bc77-­‐4d17-­‐ab5b-­‐421d89850fca      flavor_id:  performance1-­‐1      require_chef_omnibus:  latest   ! suites:      -­‐  name:  default          run_list:  recipe[cookbook::default]          attributes:
  34. 34. #rackstackatl -­‐-­‐-­‐   provisioner:      name:  chef_solo   ! platforms:      -­‐  name:  ubuntu-­‐14.04   ! driver:      name:  rackspace      rackspace_region:  IAD      server_name:  rackspace-­‐ubuntu1404      image_id:  bb02b1a3-­‐bc77-­‐4d17-­‐ab5b-­‐421d89850fca      flavor_id:  performance1-­‐1      require_chef_omnibus:  latest   ! suites:      -­‐  name:  default          run_list:  recipe[cookbook::default]          attributes:
  35. 35. #rackstackatl -­‐-­‐-­‐   provisioner:      name:  chef_solo   ! platforms:      -­‐  name:  ubuntu-­‐14.04   ! driver:      name:  rackspace      rackspace_region:  IAD      server_name:  rackspace-­‐ubuntu1404      image_id:  bb02b1a3-­‐bc77-­‐4d17-­‐ab5b-­‐421d89850fca      flavor_id:  performance1-­‐1      require_chef_omnibus:  latest   ! suites:      -­‐  name:  default          run_list:  recipe[cookbook::default]          attributes:
  36. 36. #rackstackatl -­‐-­‐-­‐   provisioner:      name:  chef_solo   ! platforms:      -­‐  name:  ubuntu-­‐14.04   ! driver:      name:  rackspace      rackspace_region:  IAD      server_name:  rackspace-­‐ubuntu1404      image_id:  bb02b1a3-­‐bc77-­‐4d17-­‐ab5b-­‐421d89850fca      flavor_id:  performance1-­‐1      require_chef_omnibus:  latest   ! suites:      -­‐  name:  default          run_list:  recipe[cookbook::default]          attributes:
  37. 37. #rackstackatl CHEF DEVELOPMENT KIT
  38. 38. #rackstackatl CHEF DEVELOPMENT KIT ChefSpec • Built on RSpec • Converges a Chef run in memory • Overrides all providers to take no action • Mock Ohai data with Fauxhai
  39. 39. #rackstackatl CHEF DEVELOPMENT KIT: CHEFSPEC https://github.com/sethvargo/chefspec/tree/master/examples
  40. 40. #rackstackatl CHEF DEVELOPMENT KIT: CHEFSPEC require  'chefspec'   ! describe  'apt_package::install'  do      let(:chef_run)  {  ChefSpec::Runner.new.converge(described_recipe)  }   !    it  'installs  a  apt_package  with  the  default  action'  do          expect(chef_run).to  install_apt_package('default_action')          expect(chef_run).to_not  install_apt_package('not_default_action')      end   end
  41. 41. #rackstackatl CHEF DEVELOPMENT KIT: CHEFSPEC require  'chefspec'   ! describe  'apt_package::install'  do      let(:chef_run)  {  ChefSpec::Runner.new.converge(described_recipe)  }   !    it  'installs  a  apt_package  with  the  default  action'  do          expect(chef_run).to  install_apt_package('default_action')          expect(chef_run).to_not  install_apt_package('not_default_action')      end   end
  42. 42. #rackstackatl CHEF DEVELOPMENT KIT: CHEFSPEC require  'chefspec'   ! describe  'apt_package::install'  do      let(:chef_run)  {  ChefSpec::Runner.new.converge(described_recipe)  }   !    it  'installs  a  apt_package  with  the  default  action'  do          expect(chef_run).to  install_apt_package('default_action')          expect(chef_run).to_not  install_apt_package('not_default_action')      end   end
  43. 43. #rackstackatl HONORABLE MENTIONS
  44. 44. #rackstackatl SERVERSPEC • Built on RSpec • Uses SSH to test your servers’ state
  45. 45. #rackstackatl SERVERSPEC describe  package('httpd')  do      it  {  should  be_installed  }   end   ! describe  service('httpd')  do      it  {  should  be_enabled      }      it  {  should  be_running      }   end   ! describe  port(80)  do      it  {  should  be_listening  }   end
  46. 46. #rackstackatl meez https://github.com/paulczar/meez
  47. 47. #rackstackatl RUBOCOP: STYLE RUBY STYLE GUIDE • code layout • strings • syntax • regex • more
  48. 48. #rackstackatl GUARD: TEST WHILE YOU WORK
  49. 49. #rackstackatl
  50. 50. #rackstackatl source  'https://rubygems.org'   ! gem  'berkshelf'   gem  'chef'   gem  'meez'   gem  'guard'   gem  'guard-­‐kitchen'   gem  'rubocop'   gem  'foodcritic'   gem  'chefspec'   gem  'test-­‐kitchen'   gem  'kitchen-­‐rackspace'   gem  'kitchen-­‐openstack'
  51. 51. #rackstackatl GET TO THE OPENSTACK STUFF
  52. 52. #rackstackatl source  'https://rubygems.org'   ! gem  'berkshelf'   gem  'chef'   gem  'meez'   gem  'guard'   gem  'guard-­‐kitchen'   gem  'rubocop'   gem  'foodcritic'   gem  'chefspec'   gem  'test-­‐kitchen'   gem  'kitchen-­‐rackspace'   gem  'kitchen-­‐openstack'
  53. 53. #rackstackatl DEMO TIME!
  54. 54. #rackstackatl54
  55. 55. #rackstackatl55
  56. 56. #rackstackatl 162.242.253.111 LET’S PLAY ON THE CLOUD
  57. 57. #rackstackatl WE’RE HIRING http://rackertalent.com
  58. 58. #rackstackatl RACKSPACE® HOSTING | 5000 WALZEM ROAD | SAN ANTONIO, TX 78218 US SALES: 1-800-961-2888 | US SUPPORT: 1-800-961-4454 | WWW.RACKSPACE.COM RACKSPACE® HOSTING | © RACKSPACE US, INC. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. | WWW.RACKSPACE.COMRACKSPACE® HOSTING | © RACKSPACE US, INC. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. | WWW.RACKSPACE.COM Hart Hoover @hhoover

×