Get Your Facts Right

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Notes on slide 1

    Background - systems, development, agile, puppet. Builds on James’ talk, a good place to get started.

    .Horror stories

    we pushed a fact that worked when you ran it with facter, but not with puppet
    I think the confine was at the wrong level or something weird like that?
    had to clusterssh into many many many machines and remove it..

    If I have to ssh into a box I’ve failed

    Simon Willison telling me one of Jesse Robbins (Amazon, now opscode) used to go around data centre and unplug things.
    Luke Kaines throw it out window

    Bug #1

    Infrastructure is code

    Productive in 4 hours.

    babel

    Language you might hear on list
    * TDD, BDD, WTF
    * problem - works on my machine!
    * problem - vague naming (domainname)

    Capture intent

    Systems view of testing - Testing from a sys admins view '['
    Destructive testing (load tests, penetration testing) - Hammer
    Test system, test environment.

    Dan north, way to describe testing, Whether at the code level, the application level or
    beyond, we can use the same thinking and the same linguistic
    constructs to describe behaviour at any level of granularity.

    Why test
    * quality pyramid, internal external
    * spaghetti code
    * broken code - ec2
    * red green refactor
    * inherent complexity in facter == difference between systems.
    * FEEDBACK and cost of change!

    Simplest thing to get the test to pass

    Our test is not actually testing what we want.
    How can we test so it works on my machine and your machine?

    language, expectations,

    mock objects

    1 Favorite

    Get Your Facts Right - Presentation Transcript

    1. Get your facts right Paul Nasrat • #puppetcamp 2009 @nasrat • pnasrat@googlemail.com
    2. http://www.flickr.com/photos/tentalemonkey/2401988558
    3. clustersshf**k
    4. if Facter.hostname[0, 5] = "tstme" int_service_domain = "tst.example.local" ext_service_domain = "tst.example.com" else int_service_domain = "example.local" ext_service_domain = "example.com" end
    5. = != ==
    6. http://www.flickr.com/photos/lifeinelgin/2533204950/
    7. http://www.history.navy.mil/photos/pers-us/uspers-h/g-hoppr.htm
    8. def can_connect?(ip,port,wait_sec=2) Timeout::timeout(wait_sec) {open(ip, port)} return true rescue return false end
    9. def can_connect?(ip,port,wait_sec=2) Timeout::timeout(wait_sec) {open(ip, port)} return true rescue return false end
    10. def can_connect?(ip,port,wait_sec=2 url = "http://#{ip}:#{port}/" Timeout::timeout(wait_sec) {open(url)} return true rescue return false end
    11. Bug #2
    12. def can_connect?(ip,port,wait_sec=2 url = "http://#{ip}:#{port}/" Timeout::timeout(wait_sec) {open(url)} return true rescue return false end
    13. def can_connect?(ip,port,wait_sec=2 url = "http://#{ip}:#{port}/" Timeout::timeout(wait_sec) {open(url)} return true rescue Timeout::Error return false rescue return false end
    14. ops == code
    15. Dev vs Ops http://www.flickr.com/photos/cayusa/627611844
    16. IV
    17. http://www.flickr.com/photos/thomasthomas/274884308/
    18. Unit Testing
    19. “Debugging is twice as hard as writing the code in the first place.” Brian Kernighan
    20. [
    21. Test-driven development
    22. Behaviour driven development
    23. £$€
    24. Feedback http://www.flickr.com/photos/altemark/273968506
    25. Tools • rspec • rake • git • mocha
    26. cd spec rake (in /Users/pnasrat/Development/facter/spec) Virtual fact - should be zone on Solaris when a zone
    27. require File.join(File.dirname(__FILE__), '..', 'spec_helper')
    28. describe Facter::Util::HostnameResolver do it "should return 'foo.example.com' when hostname returns foo.example.com" end
    29. spec --options spec.opts unit/hostname_spec.rb ./unit/hostname_spec.rb:3: uninitialized constant Facter::Util::HostnameResolver (NameError)
    30. module Facter module Util class HostnameResolver end end end describe Facter::Util::HostnameResolver do it "should return 'foo.example.com' when hostname returns foo.example.com" end
    31. Facter::Util::HostnameResolver - should return 'foo.example.com' when querying hostname returns foo.example.com (PENDING: Not Yet Implemented) Pending: Facter::Util::HostnameResolver should return 'foo.example.com' when querying hostname returns foo.example.com (Not Yet Implemented) ./unit/hostname_spec.rb:4 Finished in 0.0019 seconds 1 example, 0 failures, 1 pending
    32. describe Facter::Util::HostnameResolver do it "should return 'foo.example.com' when querying hostname returns foo.example.com" do Facter::Util::HostnameResolver.new.hostname.should == "foo.example.com" end end
    33. spec --options spec.opts unit/hostname_spec.rb Facter::Util::HostnameResolver - should return 'foo.example.com' when querying hostname returns foo.example.com (FAILED - 1) 1) NoMethodError in 'Facter::Util::HostnameResolver should return 'foo.example.com' when querying hostname returns foo.example.com' undefined method `hostname' for #<Facter::Util::HostnameResolver:0x12e71f0> ./unit/hostname_spec.rb:12: Finished in 0.002085 seconds 1 example, 1 failure
    34. module Facter module Util class HostnameResolver def hostname end end end end describe Facter::Util::HostnameResolver do it "should return 'foo.example.com' when querying hostname returns foo.example.com" do Facter::Util::HostnameResolver.new.hostname.should == "foo.example.com" end end
    35. 'Facter::Util::HostnameResolver should return 'foo.example.com' when querying hostname returns foo.example.com' FAILED expected: "foo.example.com", got: nil (using ==) ./unit/hostname_spec.rb:14:
    36. module Facter module Util class HostnameResolver def hostname "foo.example.com" end end end end
    37. Facter::Util::HostnameResolver - should return 'foo.example.com' when querying hostname returns foo.example.com Finished in 0.001872 seconds 1 example, 0 failures
    38. mock objects
    39. describe Facter::Util::HostnameResolver do it "should return 'foo.example.com' when querying hostname returns foo.example.com" do Facter::Util::Resolution.expects(:exec).with("hostname").returns("foo.example.com") Facter::Util::HostnameResolver.new.hostname.should == "foo.example.com" end end
    40. Mocha::ExpectationError in 'Facter::Util::HostnameResolver should return 'foo.example.com' when querying hostname returns foo.example.com' not all expectations were satisfied unsatisfied expectations: - expected exactly once, not yet invoked: Facter::Util::Resolution.exec('hostname')
    41. require 'facter/util/resolution' module Facter module Util class HostnameResolver def hostname Facter::Util::Resolution.exec("hostname") end end end end
    42. Questions?
    43. Further Info • rspec book - http://www.pragprog.com/ titles/achbd/the-rspec-book • TDD http://www.mockobjects.com/book/ tdd-introduction.html • IRC - #puppet #puppet-dev • github - other peoples code
    SlideShare Zeitgeist 2009

    + Paul NasratPaul Nasrat Nominate

    custom

    965 views, 1 favs, 1 embeds more stats

    Presentation from PuppetCamp

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 965
      • 962 on SlideShare
      • 3 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 16
    Most viewed embeds
    • 3 views on http://www.slideshare.net

    more

    All embeds
    • 3 views on http://www.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories