Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automated Infrastructure Testing

Ranjib Dey
September 08, 2012
190

Automated Infrastructure Testing

Testing strategies for chef managed infrastructure

Ranjib Dey

September 08, 2012
Tweet

Transcript

  1. Automated Infrastructure Testing
    Ranjib Dey
    System Administrator, ThoughtWorks

    View Slide

  2. Part 1
    What we are building?

    View Slide

  3. What you already know?

    View Slide

  4. To Code (develop functionalities)
    To Test (ensure if its working fine)

    View Slide

  5. To Code (develop functionalities)
    To Test (ensure if its working fine)
    Automate

    View Slide

  6. Enter DevOps/CD

    View Slide

  7. To Code (develop functionalities)
    To Test (ensure if its working fine)
    To Deploy (ensure if it can be released)

    View Slide

  8. To Code (develop functionalities)
    To Test (ensure if its working fine)
    To Deploy (ensure if it can be released)
    Automate

    View Slide

  9. To Code (develop functionalities)
    To Test (ensure if its working fine)
    To Deploy (ensure if it can be released)
    Automate
    Automate

    View Slide

  10. To Code
    To Test
    To Deploy
    Automate
    Automate
    CI

    View Slide

  11. To Code
    To Test
    To Deploy
    Automate
    Automate
    CI
    CD

    View Slide

  12. Part 2
    How it is different?

    View Slide

  13. Tested code
    Deployed code
    Automate

    View Slide

  14. Tested code
    Deployed code
    Automate
    Infrastructure

    View Slide

  15. Tested code
    Deployed code
    Automate
    Infrastructure
    Operations

    View Slide

  16. Tested code
    Deployed code
    Automate
    Infrastructure
    Operations
    Data

    View Slide

  17. Tested code
    Deployed code
    Automate
    Infrastructure
    Operations
    Data
    Compliance

    View Slide

  18. Tested code
    Deployed code
    Automate
    Infrastructure
    Operations
    Data
    Compliance
    End users

    View Slide

  19. Tested code
    Deployed code
    Automate
    Infrastructure
    Operations
    Data
    Compliance
    End users
    Integrations

    View Slide

  20. On infrastructure

    View Slide

  21. To Code
    To Test
    To Deploy
    Automate
    Automate

    View Slide

  22. To Code
    To Test
    To Deploy
    Automate
    Automate
    Build infrastructure

    View Slide

  23. To Code
    To Test
    To Deploy
    Automate
    Automate
    Build infrastructure
    Production
    Infrastructure

    View Slide

  24. Part 3
    On testing

    View Slide

  25. Tested code
    Deployed code
    Automate

    View Slide

  26. Tested code
    Deployed code
    Automate
    Infrastructure as Code

    View Slide

  27. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code

    View Slide

  28. View Slide

  29. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test

    View Slide

  30. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing

    View Slide

  31. View Slide

  32. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing

    View Slide

  33. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing
    Functional Testing

    View Slide

  34. Scenario: Nginx is running as a daemon
    When I run "ps aux | grep nginx"
    Then I should see “nginx:master" in the output

    View Slide

  35. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing
    Functional Testing

    View Slide

  36. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing
    Functional Testing
    Integration Testing

    View Slide

  37. describe_recipe 'nginx:configuration' do
    it 'installs version 1.0.15' do
    node[:nginx][:version].should == '1.0.15'
    file("/etc/nginx/nginx.conf").must_have(:mode, "644")
    package("nginx").must_be_installed
    service("nginx").must_be_running
    end
    end

    View Slide

  38. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Code Test
    Unit Testing
    Functional Testing
    Integration Testing
    Monitoring

    View Slide

  39. • Monitoring

    View Slide

  40. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Monitoring
    Tests Mocks

    View Slide

  41. Tested code
    Deployed code
    Automate
    Infrastructure as Code
    Monitoring
    Tests Mocks
    Analytics

    View Slide

  42. Part 4
    Cloud cometh

    View Slide

  43. Cloud

    View Slide

  44. View Slide

  45. I see more code

    View Slide

  46. I see more code
    I need more tests

    View Slide

  47. Cloud
    AWS

    View Slide

  48. Cloud
    AWS
    Rackspace
    GCE
    HP
    Joyent

    View Slide

  49. Oh yeah
    We love cross browser testing?

    View Slide

  50. Part 5
    Lessons learned

    View Slide

  51. Health of infrastructure

    View Slide

  52. Health of infrastructure
    Battle tested code

    View Slide

  53. Health of infrastructure
    Battle tested code
    Thorough Monitoring

    View Slide

  54. • Remember to build feedback system .
    – Test harness should publish metrics in the same
    system where ops and project metrics are kept.
    – Have analytics or trending system on top of the
    metrics.

    View Slide

  55. Collaborate more with
    Ops.

    View Slide

  56. Some advice
    • Remember MIME types?
    • World wont be fully automatic ever. Always
    automate the most time consuming task first.
    • No easy way out. The function domain
    requires you to understand man pages, rfps
    etc.
    • Choose a text editor rather than an Window
    manager based IDE.

    View Slide

  57. References
    • Infra-automation: http://www.opscode.com/chef/
    • Monitoring: http://www.nagios.org/
    • Lint tool: http://acrmp.github.com/foodcritic/
    • Unit testing: https://github.com/acrmp/chefspec
    • Functional testing: http://www.cucumber-chef.org/
    • Integration testing:
    https://github.com/calavera/minitest-chef-handler

    View Slide

  58. @RanjibDey
    http://ranjib.posterous.com
    http://www.dzone.com/users/ranjibd
    [email protected]

    View Slide