Test-Driven Infrastructure Development

Test-Driven Infrastructure Development

540c59627eb80644f4859bebafa5f185?s=128

Andrea Tosatto

March 10, 2017
Tweet

Transcript

  1. Test-Driven Infrastructure Development MANAGE OPS COMPLEXITY WITH TDD AND DEVOPS

    Andrea Tosatto @Open-Xchange IDI2017 @_hilbert_ atosatto andrea@ox.io
  2. WHOAMI

  3. POWERDNS Started in 1999 Open-Source since 2007 Part of Open-Xchange

    since 2015 Powering more than 30% of the internet hosted domains in the world 75% of the DNSSEC domains in the world 150mln of internet users A piece of blazing fast C++ code powering the Internet. Sometimes we also use Python. ;-) @PowerDNS powerdns/pdns
  4. WHY

  5. MY #ANSI-MOOD

  6. MY #ANSI-MOOD The moment in which my boss told me

    ”you have 2 weeks to deploy that things for that huuuuge customer running Oracle Linux 6, but maybe it was Debian… I don’t know!”
  7. PANIC

  8. CODING LIKE HELL

  9. CODING LIKE HELL

  10. ANSIBLE AT SCALE IT’S HARD • CODE QUALITY CAN EASILY

    BECOME REALLY BAD • IT’S HARD TO ENFORCE STANDARDS ACROSS THE TEAM • SOMETIMES IT’S TO VERIFY YOUR WORK • NO TESTS • NO WORKFLOW • NO DOC • NOT REALLY DEVOPS • SOMETIMES THINGS JUST DON’T GO AS EXPECTED
  11. ANSIBLE AT SCALE IT’S HARD (2)

  12. ANSIBLE AT SCALE IT’S HARD (3)

  13. REAL WORLD IS ALWAYS DIFFERENT

  14. REAL WORLD IS ALWAYS MUCH MORE COMPLEX

  15. TEST-DRIVEN DEVOPS

  16. TEST-DRIVEN DEVOPS • BUSINESS REQUIREMENTS AS TESTS • ENCODE OPS

    KNOWLEDGE AS TEST • VALIDATE YOUR ASSUMPTIONS • EASILY DEAL WITH DIFFERENT OS PLATFORMS • BE SURE TO CATCH ALL THE EDGE CASES • PREDICTABLE AUTOMATION • IDEMPOTENCY • NO SIDE EFFECTS
  17. TESTINFRA

  18. TESTINFRA

  19. TESTINFRA (2) • PYTEST FOR THE INFRASTRUCTURE • NO SERVERSPEC

    • NO KITCHEN-CI • NO RUBY • PURE PYTHON • EASY CI
  20. MODULES Command LocalCommand TestinfraBackend Sudo File User Group Interface Package

    PipPackage Process Service Supervisor Socket SystemInfo Salt Ansible PuppetResource Facter Sysctl MountPoint
  21. PACKAGES & SERVICES

  22. FILES

  23. PARAMETRIZED ASSERTIONS

  24. SHELL COMMANDS

  25. SHELL COMMANDS (2)

  26. RUN THE TESTS

  27. TESTS ARE COOL BUT WE WANT PEOPLE TO RUN THEM

  28. MOLECULE

  29. MOLECULE

  30. MOLECULE (2) • ANSIBLE ROLES DEVELOPMENT WORKFLOW TOOL • DEVELOPED

    BY SOME CISCO’S PYTHON NINJAS TO HELP CISCO DEVOPS TO DEVELOP OPENSTACK ROLES https://www.youtube.com/watch?v=5vKblNaD3fI&t=81s • OUT OF THE BOX • BOILERPLATING molecule init • LINTING molecule verify • VALIDATION molecule converge • TESTING molecule test
  31. MOLECULE.YML

  32. WORKFLOW molecule: test: sequence: - destroy - syntax - create

    - converge - idempotence - verify
  33. WORKFLOW (2)

  34. .TRAVIS.YML

  35. WE WANT TO TEST AGAINST DIFFERENT SCENARIOS

  36. MOLECULE V2

  37. MOLECULE V2 • SCENARIO BASED TESTING • ANSIBLE-BASED PROVIDERS •

    DOCKER • VAGRANT • OPENSTACK • AWS • … • NO BACK-WARD COMPATIBLE :-( • BUT, IT WILL NOT IMPACT YOUR ANSIBLE CODE, SO EASY UPGRADE! ;-)
  38. SCENARIO DEFINITION

  39. PER-SCENARIO MOLECULE.YML

  40. SCENARIO-BASED WORKFLOW

  41. TDD DEVOPS. SIMPLER BETTER FASTER STRONGER

  42. THANK YOU PS: WE’RE HIRING - https://www.open-xchange.com/jobs/