1. Trang chủ
  2. » Công Nghệ Thông Tin

Test driven infrastructure with chef, 2nd edition

308 92 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 308
Dung lượng 7,29 MB

Nội dung

www.it-ebooks.info www.it-ebooks.info SECOND EDITION Test-Driven Infrastructure with Chef Stephen Nelson-Smith www.it-ebooks.info Test-Driven Infrastructure with Chef, Second Edition by Stephen Nelson-Smith Copyright © 2014 Atalanta Systems LTD All rights reserved Printed in the United States of America Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safaribooksonline.com) For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com Editors: Mike Loukides and Meghan Blanchette Production Editor: Melanie Yarbrough Proofreader: Elise Morrison Indexer: WordCo Indexing Services October 2013: Cover Designer: Randy Comer Interior Designer: David Futato Illustrator: Rebecca Demarest Second Edition Revision History for the Second Edition: 2013-10-10: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449372200 for release details Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc Test-Driven Infrastructure with Chef, the cover image of an edible-nest swiftlet, and related trade dress are trademarks of O’Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN: 978-1-449-37220-0 [LSI] www.it-ebooks.info Table of Contents Preface vii The Philosophy of Test-Driven Infrastructure Underpinning Philosophy Infrastructure as Code The Origins of Infrastructure as Code The Principles of Infrastructure as Code The Risks of Infrastructure as Code Professionalism 2 An Introduction to Ruby 13 What Is Ruby? Grammar and Vocabulary Methods and Objects Identifiers More About Methods Classes Arrays Conditional logic Hashes Truthiness Operators Bundler 13 15 17 19 22 25 27 30 32 34 35 37 An Introduction to Chef 45 Exercise 1: Install Chef Objectives Directions Worked Example 47 47 47 48 iii www.it-ebooks.info Discussion Exercise 2: Install a User Objectives Directions Worked Example Discussion Exercise 3: Install an IRC Client Objectives Directions Worked Example Discussion Exercise 4: Install Git Objectives Directions Worked Example Discussion 49 54 54 54 54 57 61 61 61 62 66 70 70 70 71 74 Using Chef with Tools 81 Exercise 1: Ruby Objectives Directions Worked Example Discussion Exercise 2: Virtualbox Objectives Directions Worked example Discussion Exercise 3: Vagrant Objectives Directions Worked Example Discussion Conclusion 81 81 81 82 91 106 107 107 107 110 113 113 113 114 118 122 An Introduction to Test- and Behavior-Driven Development 125 The Principles of TDD and BDD A Very Brief History of Agile Software Development Test-Driven Development Behavior-Driven Development TDD and BDD with Ruby Minitest: Unit Testing for the 21st Century iv | Table of Contents www.it-ebooks.info 125 125 126 127 129 129 RSpec: The Transition to BDD Cucumber: Acceptance Testing for the Masses 133 138 A Test-Driven Infrastructure Framework 155 Test-Driven Infrastructure: A Conceptual Framework Test-Driven Infrastructure Should Be Mainstream Test-Driven Infrastructure Should Be Automated Test-Driven Infrastructure Should Be Side-Effect Aware Test-Driven Infrastructure Should Be Continuously Integrated Test-Driven Infrastructure Should Be Outside In Test-Driven Infrastructure Should Be Test-First The Pillars of Test-Driven Infrastructure Writing Tests Running Tests Provisioning Machines Feedback of Results 156 156 157 158 158 159 160 161 161 162 162 163 Test-Driven Infrastructure: A Recommended Toolchain 165 Tool Selection Unit Testing Integration Testing Acceptance Testing Testing Workflow Supporting Tools: Berkshelf Overview Getting Started Example Advantages and Disadvantages Summary and Conclusion Supporting Tools: Test Kitchen Overview Getting Started Summary and Conclusion Acceptance Testing: Cucumber and Leibniz Overview Getting Started Example Advantages and Disadvantages Summary and Conclusion Integration Testing: Test Kitchen with Serverspec and Bats Introducing Bats Introducing Serverspec 166 167 167 168 170 173 173 174 175 185 186 186 186 187 189 190 190 192 194 210 212 213 220 220 Table of Contents www.it-ebooks.info | v Templates Integration Testing: Minitest Handler Overview Getting Started Example Advantages and Disadvantages Summary and Conclusion Unit Testing: Chefspec Overview Getting Started Example Advantages and Disadvantages Summary and Conclusion Static Analysis and Linting Tools Overview Getting Started Example Advantages and Disadvantages Summary and Conclusion To Conclude 233 243 244 245 251 257 257 257 258 259 260 268 269 270 270 271 274 279 279 279 Epilogue 281 A Bibliography 283 Index 289 vi | Table of Contents www.it-ebooks.info Preface Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords Constant width bold Shows commands or other text that should be typed literally by the user Constant width italic Shows text that should be replaced with user-supplied values or by values deter‐ mined by context This icon signifies a tip, suggestion, or general note This icon indicates a warning or caution vii www.it-ebooks.info Safari® Books Online Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s lead‐ ing authors in technology and business Technology professionals, software developers, web designers, and business and crea‐ tive professionals use Safari Books Online as their primary resource for research, prob‐ lem solving, learning, and certification training Safari Books Online offers a range of product mixes and pricing programs for organi‐ zations, government agencies, and individuals Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐ fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol‐ ogy, and dozens more For more information about Safari Books Online, please visit us online How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information You can access this page at http://oreil.ly/test-driven-infra-chef To comment or ask technical questions about this book, send email to bookques tions@oreilly.com For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://www.youtube.com/oreillymedia viii | Preface www.it-ebooks.info ... A Test- Driven Infrastructure Framework 155 Test- Driven Infrastructure: A Conceptual Framework Test- Driven Infrastructure Should Be Mainstream Test- Driven Infrastructure. .. Automated Test- Driven Infrastructure Should Be Side-Effect Aware Test- Driven Infrastructure Should Be Continuously Integrated Test- Driven Infrastructure Should Be Outside In Test- Driven Infrastructure. ..www.it-ebooks.info SECOND EDITION Test- Driven Infrastructure with Chef Stephen Nelson-Smith www.it-ebooks.info Test- Driven Infrastructure with Chef, Second Edition by Stephen Nelson-Smith

Ngày đăng: 19/04/2019, 14:33

TỪ KHÓA LIÊN QUAN