Slide 1

Slide 1 text

Casualʹ Πϯϑϥςετ΁ ೖ໳ͨ͠࿩ Testing Casual Talks #2 LT

Slide 2

Slide 2 text

About me… Daichi Kamemoto (@yudoufu) • DevOps • Go! Go! Go! ʕ◔ϖ◔ʔ • PHP / iOS (Obj-C/Swift)

Slide 3

Slide 3 text

Πϯϑϥ୲౰(Ұਓ)͕ঢ়ଶ+ৼ෣͍ͷ ࣗಈςετΛಋೖͨ͠ܦݧஊͱɺ ͦͷײ૝Λ͓࿩͠·͢ɻ

Slide 4

Slide 4 text

ςετಋೖҎલ • αʔόͷߏஙɾઃఆมߋ͸શͯChefԽ • ৽ઃఆ͸ݕূαʔό(VM)ʹྲྀͯ͠νΣοΫ ̇ ƅТƅ CSPXTFSTTI

Slide 5

Slide 5 text

ςετಋೖҎલ 㸝 ƅТƅ • ͋ΕɺઃఆͪΐͬͱҧͬͨΑ͏ͩ • मਖ਼Λαʔόʹྲྀͯ͠΋͏Ұ౓νΣοΫ

Slide 6

Slide 6 text

ςετಋೖҎલ • chef͕൒୺ͳίέํͯ͠ຊ൪ͱঢ়گ͕ɻɻɻ • ΋͏Ұ౓VMΛ࡞Γͳ͓ͯ͠௨͠νΣοΫ 㸝 ƅТƅ

Slide 7

Slide 7 text

ςετಋೖҎલ • ΋͏Ұ౓ɻɻɻνΣοΫɻɻɻ • ͭΒ͍ Т

Slide 8

Slide 8 text

ChefͰ΋ਏ͍ςετ࡞ۀ • Կ౓΋ਓ͕΍Δ࡞ۀ͡Όͳ͍ • ϓϩηεͷϢʔβʔݖݶΛ֬ೝ • nginxͷઃఆΛม͑ͯϒϥ΢βϙνϙν • VMഁغͯ͠΋͏Ұ౓࡞Δ • ΠϯϑϥҰਓͩ͠μϒϧνΣοΫͳ͍ා͍

Slide 9

Slide 9 text

ʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼͦ͏ͩࣗಈςετ͠Α͏ʻ ʉY^Y^Y^Y^Y^Y^Y^Y^ʉ ʂ ƅТƅ

Slide 10

Slide 10 text

खݩͰςετ͠Α͏ • Test-kitchen • Chef Cookbook༻ͷςετϋʔωε • VMͷىಈɺ൓өɺςετ࣮ߦͳͲ • Serverspec • mizzy͞Μ࡞αʔόςετπʔϧ • RSpecͰαʔό಺෦ͷঢ়ଶςετΛهड़ ओʹͬͪ͜

Slide 11

Slide 11 text

ςετ؀ڥߏங • ྆ํChef DK(Development Kit)ʹؚ·ΕͯΔ • chefίϚϯυͰcookbook࡞ͬͯΈΔͱɻɻɻ % brew cask install virtualbox % brew cask install vagrant % brew cask install chafdk % chef generate cookbook test-cookbook

Slide 12

Slide 12 text

test-cookbook !"" .gitignore !"" .kitchen.yml !"" Berksfile !"" README.md !"" chefignore !"" metadata.rb !"" recipes # %"" default.rb !"" spec # !"" spec_helper.rb # %"" unit # %"" recipes # %"" default_spec.rb %"" test %"" integration !"" default # %"" serverspec # %"" default_spec.rb %"" helpers %"" serverspec %"" spec_helper.rb ࠷ॳ͔Β ͋Δʂ ࠷ॳ͔Β ͋Δʂ

Slide 13

Slide 13 text

࣮ߦ • .kitchen.ymlΛ؀ڥʹ͋ΘͤΔ(OSͱ͔) • *_spec.rbϑΝΠϧʹςετΛॻ͍࣮ͯߦ % cd test-cookbook % kitchen verify # ςετ࣮ߦ

Slide 14

Slide 14 text

ʘaa٩ Т وʗ ࣗಈςετԽʂ ˞͜ͷޙɺαʔό$*΋͠·ͨ͠

Slide 15

Slide 15 text

ࣗಈςετԽͯ͠ಘͨ΋ͷ • ϒϥ΢βϙνϙνΛܸୀͨ͠ • αʔόΞΫηε͸೉ղͳ֬ೝ or ࠷ऴ֬ೝͷΈ • ֬ೝָ͕ʹͳͬͯվળ଎౓্͕͕ͬͨ • ࣗ෼ͷνΣοΫϛεͷෆ͕҆ফ͑ͨ • άϦʔϯͷؾ࣋ͪΑ͞ΛຯΘͬͨ(˕´∀`)Νϋʔ

Slide 16

Slide 16 text

ͦͷޙɻɻɻ • ໘౗ͳઃఆมߋ͕෣͍ࠐΉ • nginxͷpath֊૚ຖʹCache-Control etcͷ ϔομௐ੔ ̇ ƅТƅ

Slide 17

Slide 17 text

ෳࡶͳઃఆ͸ಈ࡞֬ೝ͕૿͑Δ • Serverspec͸ঢ়ଶςετ(಺෦ͷ֬ೝ)ͷΈ • ઃఆϑΝΠϧ͸ςετͰ͖ͯ΋ɺಈ࡞ࣗମ͸ ϒϥ΢βνΣοΫ 㸝 ƅТƅ CSPXTFSTTI

Slide 18

Slide 18 text

ʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼϒϥ΢βϙνϙνͷ࠶དྷʻ ʉY^Y^Y^Y^Y^Y^Y^Y^ʉ 㸝 ƅТƅ ΍ɺҰԠDVSM͚ͩͲ͞ɻɻɻ

Slide 19

Slide 19 text

ʊਓਓਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼΑΖ͍͠ɺͳΒ͹ৼ෣͍ςετͩʻ ʉY^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ʉ ʂ ƅТƅ

Slide 20

Slide 20 text

ৼ෣͍ςετͷࣗಈԽ • Infrataster • ΫοΫύουͷryotarai͞Μ࡞ • RSpecͰॻ͚Δৼ෣͍ςετπʔϧ • ࣮ࡍʹΞΫηεͯ͠ϨεϙϯεΛςετ • CapybaraΛ࢖ͬͨςετ΋ॻ͚Δ • RSpecಉ࢜ɺServerspecͱ૊Έ߹Θͤ΍͍͢

Slide 21

Slide 21 text

InfratasterΛtest-kitchenͰ࢖͏ • ຊདྷɺInfrataster͸αʔό֎෦͔ΒͷςετΛ ૝ఆͨ͠΋ͷ • ProxyΛ͏·͘΍ΔػೳͳͲ͕͋Δ΄Ͳ • test-kitchenͷVM಺Ͱ࢖͏લఏͰ͸ͳ͍ • Ͳ͏͢Δ͔ɻɻɻ

Slide 22

Slide 22 text

ํ๏Λ୳ͨ͠Β • Issueʹ࢑ఆରԠࡦ͕ࡌͬͯͨ • https://github.com/ryotarai/infrataster/ issues/37

Slide 23

Slide 23 text

test-kitchenରԠํ๏ • Gemfileͷ௥Ճͱɺspec_helperͰͷLoad test %"" integration !"" default # %"" serverspec # !"" Gemfile # %"" default_spec.rb %"" helpers %"" serverspec %"" spec_helper.rb

Slide 24

Slide 24 text

Gemfileͷ௥Ճ • InfratasterΛGemfileʹ௥Ճ % ${EDITOR} test/integration/default/ serverspec/Gemfile ``` source 'https://rubygems.org' gem 'infrataster' ```

Slide 25

Slide 25 text

spec_helperͰLoad • spec_helperͷ಺༰Λमਖ਼ % ${EDITOR} test/integration/helpers/ serverspec/spec_helper.rb ``` require 'serverspec' require 'infrataster/rspec' set :backend, :exec Infrataster::Server.define(:app, ‘127.0.0.1') ``` ର৅αʔόΛ ϩʔΧϧʹ

Slide 26

Slide 26 text

ςετΛॻ͍࣮ͯߦ • .*_spec.rbϑΝΠϧʹςετΛॻ͍࣮ͯߦ • ServerspecͱϑΝΠϧ͕ࠞͬͯͯ͟΋OK % kitchen verify

Slide 27

Slide 27 text

ʘaa٩ Т وʗ ϩʔΧϧͰৼ෣͍ςετ

Slide 28

Slide 28 text

ৼ෣͍ςετʹΑͬͯಘͨ΋ͷ • ϒϥ΢βϙνϙνΛᓲ໓ͨ͠ • ·ͣςετʹॻ͍ͯࢼ͢Α͏ʹͳͬͨ • ຊ൪൓өʹ҆৺ײ͕ग़͖ͯͨ • ઃఆมߋʹΑΔσάϨΛະવʹ๷͗΍͘͢ͳͬͨ • άϦʔϯ͕·͢·͢ؾ࣋ͪΑ͘ͳͬͨ(˕´∀`)

Slide 29

Slide 29 text

·ͱΊɾϝϦοτͱײ૝ • ཁ݅ɾ࢓༷ͷ໌จԽ • σάϨ΍Τϯόά๷ࢭͷ҆৺ײ • νΣοΫ࡞ۀͷେ͖ͳܰݮ • ͜ΕΒͷޮՌʹجͮ͘ɺվળ଎౓ͷ޲্ • ࣮࣭4ߦͷઃఆͰςετ૊ΈࠐΊͯίεύ࠷ߴ • Πϯϑϥ୲౰ͷਓ͸ͥͻ΍Γ·͠ΐ͏

Slide 30

Slide 30 text

Let’s Enjoy Infra Test! ʘ\\٩( 'ω' )و //ʗ