 Hi, Habrayuzer! Today I would like to talk about tools that make it easier to test kukbuk. What is the actual problem? As the scale of infrastructure grows, it becomes more difficult to monitor dependencies and the consequences of making changes to kukbooks, and the question of testing them is on the agenda. Tools such as foodcritics, chefspec, minitest, test kitchen help solve these problems ...
 Hi, Habrayuzer! Today I would like to talk about tools that make it easier to test kukbuk. What is the actual problem? As the scale of infrastructure grows, it becomes more difficult to monitor dependencies and the consequences of making changes to kukbooks, and the question of testing them is on the agenda. Tools such as foodcritics, chefspec, minitest, test kitchen help solve these problems ...mkdir C:\vagrant && cd C:\vagrantC:\vagrant>vagrant init-- config.vm.box = "base"++ config.vm.box = "precise32"C:\vagrant>vagrant upmkdir C:\devkit && cd C:\devkitC:\devkit>ruby dk.rb init[INFO] found RubyInstaller v1.9.3 at C:/Ruby193Initialization complete! Please review and modify the auto-generated'config.yml' file to ensure it contains the root directories to allof the installed Rubies you want enhanced by the DevKit.C:\DevKit>ruby dk.rb install[INFO] Updating convenience notice gem override for 'C:/Ruby193'[INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'C:\DevKit>echo %PATH%C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Ruby193\binsetx PATH "C:\DevKit\mingw\bin\;C:\DevKit\bin\"setx PATH "%PATH%;C:\DevKit\mingw\bin\;C:\DevKit\bin\" /M> > > .C:\Users\cc>echo %PATH%C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Ruby193\bin;C:\DevKit\mingw\bin\;C:\DevKit\bin\C:\>mkdir C:\kitchen && cd C:\kitchenC:\DevKit>gem install bundlerFetching: bundler-1.5.2.gem (100%)Successfully installed bundler-1.5.21 gem installedInstalling ri documentation for bundler-1.5.2...Installing RDoc documentation for bundler-1.5.2...source 'https://rubygems.org'gem 'berkshelf', '~> 2.0.0' # use for manage cookbook dependenciesgem 'chef', '~> 11.6.0'gem 'chef-zero'gem 'json', '1.7.7' # needed for conflict resolutiongem 'kitchen-vagrant'gem 'test-kitchen'C:\kitchen>bundle installFetching gem metadata from rubygems.org.......Fetching additional metadata from rubygems.org..Resolving dependencies...Installing i18n (0.6.9)Installing multi_json (1.8.4)Installing activesupport (3.2.16)Installing test-kitchen (1.0.0)Installing kitchen-vagrant (0.11.3)Using bundler (1.5.2)Your bundle is complete!Use `bundle show [gemname]` to see where a bundled gem is installed.mkdir C:\kitchen\cookbooks && cd C:\kitchen\cookbooks && knife cookbook site download sendmailC:\kitchen>kitchen initcreate .kitchen.ymlcreate test/integration/defaultcreate .gitignoreappend .gitignoreappend .gitignoreC:\kitchen>kitchen test.....................←[0m[2014-01-11T10:17:15+00:00] INFO: *** Chef 11.8.2 ***←[36m←[0m[2014-01-11T10:17:15+00:00] INFO: Chef-client pid: 1169←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Setting the run_list to ["recipe[sendmail]"] from JSON←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Run List is [recipe[sendmail]]←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Run List expands to [sendmail]←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Starting Chef Run for default-ubuntu-1204←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Running start handlers←[36m←[0m[2014-01-11T10:17:16+00:00] INFO: Start handlers complete.←[36m←[0mCompiling Cookbooks...←[0m←[36m←[0mConverging 2 resources←[0m←[36m←[0mRecipe: sendmail::default←[0m←[36m←[0m * package[sendmail] action install←[0m[2014-01-11T10:17:16+00:00] INFO: Processing package[sendmail] action install(sendmail::default line 1)←[36m←[0m←[32m←[36m←[0m - install version 8.14.4-2ubuntu2 of package sendmail←[0m←[36m←[0m←[0m←[36m←[0m * service[sendmail] action enable←[0m[2014-01-11T10:17:27+00:00] INFO: Processing service[sendmail] action enable (sendmail::default line 6)←[36m←[0m[2014-01-11T10:17:27+00:00] INFO: service[sendmail] enabled←[36m←[0m←[32m←[36m←[0m - enable service service[sendmail]←[0m←[36m←[0m←[0m←[36m←[0m * service[sendmail] action start←[0m[2014-01-11T10:17:27+00:00] INFO: Processing service[sendmail] action start (sendmail::default line 6)←[36m←[0m (up to date)←[0m←[36m←[0m[2014-01-11T10:17:27+00:00] INFO: Chef Run complete in 11.695990777 seconds←[36m←[0m[2014-01-11T10:17:27+00:00] INFO: Running report handlers←[36m←[0m[2014-01-11T10:17:27+00:00] INFO: Report handlers complete←[36m←[0mChef Client finished, 2 resources updated←[0m←[36m←[0m←[36m Finished converging <default-ubuntu-1204> (0m29.54s).←[0m←[36m-----> Setting up <default-ubuntu-1204>←[0m←[36m Finished setting up <default-ubuntu-1204> (0m0.00s).←[0m←[36m-----> Verifying <default-ubuntu-1204>←[0m←[36m Finished verifying <default-ubuntu-1204> (0m0.00s).←[0m←[36m-----> Destroying <default-ubuntu-1204>←[0m←[36m [kitchen::driver::vagrant command] BEGIN (vagrant destroy -f)←[0m←[36m [default] Forcing shutdown of VM...←[0m←[36m [default] Destroying VM and associated drives...←[0m←[36m [kitchen::driver::vagrant command] END (0m0.00s)←[0m←[36m Vagrant instance <default-ubuntu-1204> destroyed.←[0m←[36m Finished destroying <default-ubuntu-1204> (0m4.85s).←[0m←[36m Finished testing <default-ubuntu-1204> (1m16.33s).←[0m-----> Kitchen is finished. (1m16.69s)C:\kitchen>vagrant plugin install vagrant-berkshelfInstalling the 'vagrant-berkshelf' plugin. This can take a few minutes...Installed the plugin 'vagrant-berkshelf (1.3.7)'!C:\kitchen>berks init chef-cookcreate chef-cook/Berksfilecreate chef-cook/Thorfilecreate chef-cook/.gitignorerun git init from "./chef-cook"C:/Ruby193/bin/berks: No such file or directory - git initcreate chef-cook/Gemfilecreate .kitchen.ymlappend Thorfilecreate test/integration/defaultappend Gemfileappend GemfileYou must run `bundle install' to fetch any new gems.create chef-cook/VagrantfileSuccessfully initializedcd C:\kitchen\chef-cook && bundle installmkdir C:\kitchen\chef-cook\cookbooks && cd C:\kitchen\chef-cook\cookbooks && berks cookbook mytestC:\kitchen\chef-cook\.kitchen.yml---suites:- name: defaultrun_list: ["recipe[mytest]"]attributes: {}C:\kitchen\chef-cook>kitchen testERROR: Cookbook mytest not found. If you're loading mytest from another cookbook, make sure you configure the dependency in your metadatacookbook 'mytest', :path => 'cookbooks/mytest'include_recipe 'sendmail'depends 'sendmail'site :opscodecookbook 'sendmail'cookbook 'mytest', :path => 'cookbooks/mytest'C:\kitchen\chef-cook>kitchen conerge....←[0m←[36m Resolving cookbook dependencies with Berkshelf...←[0mInstalling sendmail (0.1.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'Using mytest (0.1.0) at './cookbooks/mytest'....←[0m * package[sendmail] action install←[0m[2014-01-15T08:00:44+00:00] INFO: Processing package[sendmail] action install (sendmail::default line 1)←[....←[0mChef Client finished, 2 resources updated←[0m←[36m←[0m←[36m Finished converging <default-ubuntu-1204> (0m18.25s).←[0m-----> Kitchen is finished. (0m18.68s)Source: https://habr.com/ru/post/209238/
All Articles